1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//! Types and traits for working with the [Matrix](https://matrix.org) protocol.
//!
//! # Getting started
//!
//! If you want to build a Matrix client or bot, have a look at [matrix-rust-sdk](https://github.com/matrix-org/matrix-rust-sdk#readme).
//! It builds on Ruma and includes handling of state storage, end-to-end encryption and many other
//! useful things.
//!
//! For homeservers, bridges and harder-to-categorize software that works with Matrix, you're at the
//! right place. To get started, add `ruma` to your dependencies:
//!
//! ```toml
//! # crates.io release
//! ruma = { version = "0.15.0", features = ["..."] }
//! # git dependency
//! ruma = { git = "https://github.com/ruma/ruma", branch = "main", features = ["..."] }
//! ```
//!
//! You can find a low level Matrix client in the [ruma-client repository](https://github.com/ruma/ruma-client).
//!
//! You can also find a small number of examples in our dedicated [ruma-examples repository](https://github.com/ruma/ruma-examples).
//!
//! # Status
//!
//! Ruma supports all events and REST endpoints of Matrix 1.18.
//!
//! Only room versions enforcing canonical JSON (introduced with room version 6) are supported. Room
//! versions 1 through 5 are supported on a best effort basis, but a missing feature or an
//! incompatibility with a homeserver implementation are not considered bugs. Clients should be able
//! to work with those room versions, granted parts of the room might break in some unconventional
//! cases, but homeservers based on Ruma **should not** advertise support for them.
//!
//! # Features
//!
//! 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 the `matrix` feature of `ruma-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`, where `XXXX` is the MSC number -- Upcoming Matrix features that may be
//! subject to change or removal.
//! * `unstable-uniffi` -- Enables UniFFI bindings by adding conditional `uniffi` derives to _some_
//! types. This feature is currently a work in progress and, thus, unstable.
//!
//! ## Common features
//!
//! These submodules are usually activated by the API features when needed:
//!
//! * `api`
//! * `events`
//! * `signatures`
//!
//! # Compile-time `cfg` settings
//!
//! These settings are accepted at compile time to configure the generated code. They can be set
//! using the `RUSTFLAGS` environment variable like this:
//!
//! ```shell
//! RUSTFLAGS="--cfg {key}=\"{value}\""
//! ```
//!
//! or in `.cargo/config.toml`:
//!
//! ```toml
//! # General setting for all targets, overridden by per-target `rustflags` setting if set.
//! [build]
//! rustflags = ["--cfg", "{key}=\"{value}\""]
//!
//! # Per-target setting.
//! [target.<triple/cfg>]
//! rustflags = ["--cfg", "{key}=\"{value}\""]
//! ```
//!
//! 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, like
//! this:
//!
//! ```shell
//! {UPPERCASE_KEY}="{value}"
//! ```
//!
//! * `ruma_identifiers_storage` -- Choose the inner representation of the identifier types
//! generated with the `ruma_id` attribute macro. If the setting is not set or has an unknown
//! value, the owned identifiers use a `Box<str>` internally. The following values are also
//! supported:
//!
//! * `Arc` -- Use an `Arc<str>`.
//!
//! This setting can also be configured by setting the `RUMA_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 the
//! `RUMA_UNSTABLE_EXHAUSTIVE_TYPES` environment variable.
pub use ruma_events as events;
pub use ruma_html as html;
pub use ruma_signatures as signatures;
pub use ruma_state_res as state_res;
/// (De)serializable types for various [Matrix APIs][apis] requests and responses and abstractions
/// for them.
///
/// [apis]: https://spec.matrix.org/v1.18/#matrix-apis
/// Canonical JSON types and related functions.
pub use assign;
pub use ;
pub use JsOption;
pub use LanguageTag;
pub use ;
pub use web_time as time;