Expand description
Types and traits for working with the Matrix protocol.
This crate re-exports things from all of the other ruma crates so you don’t have to manually keep all the versions in sync.
Which crates are re-exported can be configured through cargo features.
⚠ Some details might be missing because rustdoc has trouble with re-exports so you may need to refer to other crates’ documentations.
🛈 For internal consistency, Ruma uses American spelling for variable names. Names may differ in the serialized representation, as the Matrix specification has a mix of British and American English.
§API features
Depending on which parts of Matrix are relevant to you, activate the following features:
appservice-api
– Application Service API.client-api
– Client-Server API.federation-api
– Server-Server (Federation) API.identity-service-api
– Identity Service API.push-gateway-api
– Push Gateway API.
These features have client
- and server
-optimized variants that are enabled respectively
with the -c
and -s
suffixes. For example:
client-api-c
– The Client-Server API optimized for the client side.client-api-s
– The Client-Server API optimized for the server side.
§Compatibility features
By default, the ruma crates are only able to handle strictly spec-compliant data and behaviour. However, due to the fact that Matrix is federated, that it is used by various implementations that might have different bugs, and that much of its data is immutable, they need to be able to interoperate with data that might differ slightly from the specification.
This is the role of the compat-*
cargo features. They allow the crates be more tolerant of
external data and incoming requests for known and reasonable deviations from the spec, usually
for historical reasons. They however do not permit the ruma crates to generate data that is not
spec-compliant.
Each cargo feature is documented briefly in the cargo manifest of the crate, and more thoroughly where the feature applies.
§Convenience features
These features are only useful if you want to use a method that requires it:
rand
– Generate random identifiers.markdown
– Parse markdown to construct messages.html
– Parse HTML to sanitize it or navigate its tree.html-matrix
– Enables thematrix
feature ofruma-html
to parse HTML elements data to typed data as suggested by the Matrix Specification.
§Unstable features
By using these features, you opt out of all semver guarantees Ruma otherwise provides:
unstable-mscXXXX
, whereXXXX
is the MSC number – Upcoming Matrix features that may be subject to change or removal.
§Common features
These submodules are usually activated by the API features when needed:
api
events
signatures
§ruma-client
features
The client
feature activates ruma::client
, and client-ext-client-api
activates
ruma-client
s client-api
feature. All other client-*
features activate the same feature
without the client-
prefix on ruma-client
. See the crate’s documentation for the effect of
these features.
If you are viewing this on docs.rs
, you can have a look at the feature dependencies by
clicking Feature flags in the toolbar at the top.
§Compile-time cfg
settings
These settings are accepted at compile time to configure the generated code. They can be set as
--cfg={key}={value}
using RUSTFLAGS
or .cargo/config.toml
(under [build]
-> rustflags = ["..."]
). They can also be configured using an environment variable at compile time, which has
the benefit of not requiring to re-compile the whole dependency chain when their value is
changed.
ruma_identifiers_storage
– Choose the inner representation ofOwned*
wrapper types for identifiers. By default they useBox
, setting the value toArc
makes them useArc
. This can also be configured by setting theRUMA_IDENTIFIERS_STORAGE
environment variable.ruma_unstable_exhaustive_types
– Most types in Ruma are marked as non-exhaustive to avoid breaking changes when new fields are added in the specification. This setting compiles all types as exhaustive. By enabling this feature you opt out of all semver guarantees Ruma otherwise provides. This can also be configured by setting theRUMA_UNSTABLE_EXHAUSTIVE_TYPES
environment variable.
Re-exports§
pub use assign::assign;
pub use js_int::int;
pub use js_int::uint;
pub use js_int::Int;
pub use js_int::UInt;
pub use js_option::JsOption;
pub use web_time as time;
Modules§
- api
api
- (De)serializable types for various Matrix APIs requests and responses and abstractions for them.
- authentication
- Common types for authentication.
- canonical_
json canonical-json
- Canonical JSON types and related functions.
- client
client
- A minimal Matrix client library.
- directory
- Common types for room directory endpoints.
- encryption
- Common types for encryption related tasks.
- events
events
- (De)serializable types for the events in the Matrix specification. These types are used by other Ruma crates.
- html
html
- Opinionated HTML parsing and manipulating library.
- http_
headers - Helpers for HTTP headers.
- matrix_
uri - Matrix URIs.
- media
- Common types and functions for the content repository.
- power_
levels - Common types for the
m.room.power_levels
event. - presence
- Common types for the presence module.
- push
- Common types for the push notifications module.
- room
- Common types for rooms.
- serde
- (De)serialization helpers for other Ruma crates.
- server_
util server-util
- Collection of helpers for implementing Matrix homeservers using Ruma.
- signatures
signatures
- Digital signatures according to the Matrix specification.
- space
- Common types for spaces.
- state_
res state-res
- thirdparty
- Common types for the third party networks module.
- to_
device - Common types for the Send-To-Device Messaging
- user_id
- Matrix user identifiers.
Macros§
- base64_
public_ key - Compile-time checked
Base64PublicKey
construction. - device_
id - Shorthand for
<&DeviceId>::from
. - event_
id - Compile-time checked
EventId
construction. - metadata
- Convenient constructor for
Metadata
constants. - mxc_uri
- Compile-time checked
MxcUri
construction. - owned_
base64_ public_ key - Compile-time checked
OwnedBase64PublicKey
construction. - owned_
device_ id - Shorthand for
OwnedDeviceId::from
. - owned_
event_ id - Compile-time checked
OwnedEventId
construction. - owned_
mxc_ uri - Compile-time checked
OwnedMxcUri
construction. - owned_
room_ alias_ id - Compile-time checked
OwnedRoomAliasId
construction. - owned_
room_ id - Compile-time checked
OwnedRoomId
construction. - owned_
server_ name - Compile-time checked
OwnedServerName
construction. - owned_
server_ signing_ key_ version - Compile-time checked
OwnedServerSigningKeyVersion
construction. - owned_
session_ id - Compile-time checked
OwnedSessionId
construction. - owned_
user_ id - Compile-time checked
OwnedUserId
construction. - room_
alias_ id - Compile-time checked
RoomAliasId
construction. - room_id
- Compile-time checked
RoomId
construction. - room_
version_ id - Compile-time checked
RoomVersionId
construction. - server_
name - Compile-time checked
ServerName
construction. - server_
signing_ key_ version - Compile-time checked
ServerSigningKeyVersion
construction. - session_
id - Compile-time checked
SessionId
construction. - user_id
- Compile-time checked
UserId
construction.
Structs§
- Base64
Public Key - A public key encoded using unpadded base64, used as an identifier for cross-signing keys.
- Base64
Public KeyOr Device Id - A Matrix ID that can be either a
DeviceId
or aBase64PublicKey
. - Client
client-ext-client-api
- A client for the Matrix client-server API.
- Client
Secret - A client secret.
- Device
Id - A Matrix device ID.
- EventId
- A Matrix event ID.
- KeyId
- A key algorithm and key name delimited by a colon.
- Matrix
ToUri - The
matrix.to
URI representation of a user, room or event. - Matrix
Uri - The
matrix:
URI representation of a user, room or event. - Milli
Seconds Since Unix Epoch - A timestamp represented as the number of milliseconds since the unix epoch.
- MxcUri
- A URI that should be a Matrix-spec compliant MXC URI.
- OneTime
KeyName - The name of a one-time or fallback key.
- Owned
Base64 Public Key - Owned variant of Base64PublicKey
- Owned
Base64 Public KeyOr Device Id - Owned variant of Base64PublicKeyOrDeviceId
- Owned
Client Secret - Owned variant of ClientSecret
- Owned
Device Id - Owned variant of DeviceId
- Owned
Event Id - Owned variant of EventId
- Owned
KeyId - Owned variant of KeyId
- Owned
MxcUri - Owned variant of MxcUri
- Owned
OneTime KeyName - Owned variant of OneTimeKeyName
- Owned
Room Alias Id - Owned variant of RoomAliasId
- Owned
Room Id - Owned variant of RoomId
- Owned
Room OrAlias Id - Owned variant of RoomOrAliasId
- Owned
Server Name - Owned variant of ServerName
- Owned
Server Signing KeyVersion - Owned variant of ServerSigningKeyVersion
- Owned
Session Id - Owned variant of SessionId
- Owned
Transaction Id - Owned variant of TransactionId
- Owned
User Id - Owned variant of UserId
- Owned
Voip Id - Owned variant of VoipId
- Room
Alias Id - A Matrix room alias ID.
- RoomId
- A Matrix room ID.
- Room
OrAlias Id - A Matrix room ID or a Matrix room alias ID.
- Seconds
Since Unix Epoch - A timestamp represented as the number of seconds since the unix epoch.
- Server
Name - A Matrix-spec compliant server name.
- Server
Signing KeyVersion - The version of a homeserver signing key.
- Session
Id - A session ID.
- Signatures
- Map of all signatures, grouped by entity.
- Transaction
Id - A Matrix transaction ID.
- UserId
- A Matrix user ID.
- VoipId
- A VoIP identifier.
Enums§
- Canonical
Json Error canonical-json
- The set of possible errors when serializing to canonical JSON.
- Canonical
Json Value canonical-json
- Represents a canonical JSON value as per the Matrix specification.
- Device
KeyAlgorithm - The algorithms for the device keys defined in the Matrix spec.
- Event
Encryption Algorithm - An encryption algorithm to be used to encrypt messages sent to a room.
- IdParse
Error - An error encountered when trying to parse an invalid ID string.
- KeyDerivation
Algorithm - A key algorithm to be used to generate a key from a passphrase.
- Matrix
IdError - An error occurred while validating a
MatrixId
. - Matrix
ToError - An error occurred while validating a
matrix.to
URI. - Matrix
UriError - An error occurred while validating a
MatrixURI
. - MxcUri
Error - An error occurred while validating an MXC URI.
- OneTime
KeyAlgorithm - The algorithms for one-time and fallback keys defined in the Matrix spec.
- Room
Version Id - A Matrix room version ID.
- Signing
KeyAlgorithm - The signing key algorithms defined in the Matrix spec.
- Voip
Version Id - A Matrix VoIP version ID.
- Voip
Version IdError - An error occurred while validating a
VoipVersionId
.
Traits§
- KeyAlgorithm
- The algorithm of a key.
- KeyName
- Helper trait to validate the name of a key.
Type Aliases§
- Canonical
Json Object canonical-json
- The inner type of
CanonicalJsonValue::Object
. - Cross
Signing KeyId - Algorithm + key name for cross-signing keys.
- Cross
Signing OrDevice Signatures - Map of cross-signing or device signatures, grouped by user.
- Cross
Signing OrDevice Signing KeyId - Algorithm + key name for cross-signing or device signing keys.
- Device
KeyId - Algorithm + key name for device keys.
- Device
Signatures - Map of device signatures, grouped by user.
- Device
Signing KeyId - Algorithm + key name for device signing keys.
- Entity
Signatures - Map of key identifier to signature values.
- OneTime
KeyId - Algorithm + key name for one-time and fallback keys.
- Owned
Cross Signing KeyId - Algorithm + key name for cross-signing keys.
- Owned
Cross Signing OrDevice Signing KeyId - Algorithm + key name for cross-signing or device signing keys.
- Owned
Device KeyId - Algorithm + key name for device keys.
- Owned
Device Signing KeyId - Algorithm + key name for [device signing] keys.
- Owned
OneTime KeyId - Algorithm + key name for one-time and fallback keys.
- Owned
Server Signing KeyId - Algorithm + key name for homeserver signing keys.
- Owned
Signing KeyId - Algorithm + key name for signing keys.
- Server
Signatures - Map of server signatures, grouped by server.
- Server
Signing KeyId - Algorithm + key name for homeserver signing keys.
- Signing
KeyId - Algorithm + key name for signing keys.