ruma/lib.rs
1#![doc(html_favicon_url = "https://ruma.dev/favicon.ico")]
2#![doc(html_logo_url = "https://ruma.dev/images/logo.png")]
3//! Types and traits for working with the [Matrix](https://matrix.org) protocol.
4//!
5//! This crate re-exports things from all of the other ruma crates so you don't
6//! have to manually keep all the versions in sync.
7//!
8//! Which crates are re-exported can be configured through cargo features.
9//!
10//! > ⚠ Some details might be missing because rustdoc has trouble with re-exports so you may need
11//! > to refer to other crates' documentations.
12//!
13//! > 🛈 For internal consistency, Ruma uses American spelling for variable names. Names may differ
14//! > in the serialized representation, as the Matrix specification has a mix of British and
15//! > American English.
16//!
17//! # API features
18//!
19//! Depending on which parts of Matrix are relevant to you, activate the following features:
20//!
21//! * `appservice-api` -- Application Service API.
22//! * `client-api` -- Client-Server API.
23//! * `federation-api` -- Server-Server (Federation) API.
24//! * `identity-service-api` -- Identity Service API.
25//! * `push-gateway-api` -- Push Gateway API.
26//!
27//! These features have `client`- and `server`-optimized variants that are enabled respectively
28//! with the `-c` and `-s` suffixes. For example:
29//! * `client-api-c` -- The Client-Server API optimized for the client side.
30//! * `client-api-s` -- The Client-Server API optimized for the server side.
31//!
32//! # Compatibility feature
33//!
34//! * `compat` increases compatibility with other parts of the Matrix ecosystem, at the expense of
35//! deviating from the specification.
36//!
37//! # Convenience features
38//!
39//! These features are only useful if you want to use a method that requires it:
40//!
41//! * `rand` -- Generate random identifiers.
42//! * `markdown` -- Parse markdown to construct messages.
43//! * `html` -- Parse HTML to sanitize it or navigate its tree.
44//! * `html-matrix` -- Enables the `matrix` feature of `ruma-html` to parse HTML elements data to
45//! typed data as suggested by the Matrix Specification.
46//!
47//! # Unstable features
48//!
49//! By using these features, you opt out of all semver guarantees Ruma otherwise provides:
50//!
51//! * `unstable-mscXXXX`, where `XXXX` is the MSC number -- Upcoming Matrix features that may be
52//! subject to change or removal.
53//! * `unstable-unspecified` -- Undocumented Matrix features that may be subject to change or
54//! removal.
55//!
56//! # Common features
57//!
58//! These submodules are usually activated by the API features when needed:
59//!
60//! * `api`
61//! * `events`
62//! * `signatures`
63//!
64//! # `ruma-client` features
65//!
66//! The `client` feature activates [`ruma::client`][client], and `client-ext-client-api` activates
67//! `ruma-client`s `client-api` feature. All other `client-*` features activate the same feature
68//! without the `client-` prefix on `ruma-client`. See the crate's documentation for the effect of
69//! these features.
70//!
71//! If you are viewing this on `docs.rs`, you can have a look at the feature dependencies by
72//! clicking **Feature flags** in the toolbar at the top.
73//!
74//! # Compile-time `cfg` settings
75//!
76//! These settings are accepted at compile time to configure the generated code. They can be set as
77//! `--cfg={key}={value}` using `RUSTFLAGS` or `.cargo/config.toml` (under `[build]` -> `rustflags =
78//! ["..."]`). They can also be configured using an environment variable at compile time, which has
79//! the benefit of not requiring to re-compile the whole dependency chain when their value is
80//! changed.
81//!
82//! * `ruma_identifiers_storage` -- Choose the inner representation of `Owned*` wrapper types for
83//! identifiers. By default they use [`Box`], setting the value to `Arc` makes them use
84//! [`Arc`](std::sync::Arc). This can also be configured by setting the `RUMA_IDENTIFIERS_STORAGE`
85//! environment variable.
86//! * `ruma_unstable_exhaustive_types` -- Most types in Ruma are marked as non-exhaustive to avoid
87//! breaking changes when new fields are added in the specification. This setting compiles all
88//! types as exhaustive. By enabling this feature you opt out of all semver guarantees Ruma
89//! otherwise provides. This can also be configured by setting the
90//! `RUMA_UNSTABLE_EXHAUSTIVE_TYPES` environment variable.
91
92#![warn(missing_docs)]
93#![cfg_attr(docsrs, feature(doc_auto_cfg))]
94
95#[cfg(feature = "client")]
96#[doc(inline)]
97pub use ruma_client as client;
98#[cfg(feature = "events")]
99#[doc(inline)]
100pub use ruma_events as events;
101#[cfg(feature = "html")]
102#[doc(inline)]
103pub use ruma_html as html;
104#[cfg(feature = "server-util")]
105#[doc(inline)]
106pub use ruma_server_util as server_util;
107#[cfg(feature = "signatures")]
108#[doc(inline)]
109pub use ruma_signatures as signatures;
110#[cfg(feature = "state-res")]
111#[doc(inline)]
112pub use ruma_state_res as state_res;
113
114/// (De)serializable types for various [Matrix APIs][apis] requests and responses and abstractions
115/// for them.
116///
117/// [apis]: https://spec.matrix.org/latest/#matrix-apis
118#[cfg(feature = "api")]
119pub mod api {
120 #[cfg(any(feature = "appservice-api-c", feature = "appservice-api-s"))]
121 #[doc(inline)]
122 pub use ruma_appservice_api as appservice;
123 #[cfg(any(feature = "client-api-c", feature = "client-api-s"))]
124 #[doc(inline)]
125 pub use ruma_client_api as client;
126 // The metadata macro is also exported at the crate root because `#[macro_export]` always
127 // places things at the crate root of the defining crate and we do a glob re-export of
128 // `ruma_common`, but here is the more logical (preferred) location.
129 pub use ruma_common::{api::*, metadata};
130 #[cfg(any(feature = "federation-api-c", feature = "federation-api-s"))]
131 #[doc(inline)]
132 pub use ruma_federation_api as federation;
133 #[cfg(any(feature = "identity-service-api-c", feature = "identity-service-api-s"))]
134 #[doc(inline)]
135 pub use ruma_identity_service_api as identity_service;
136 #[cfg(any(feature = "push-gateway-api-c", feature = "push-gateway-api-s"))]
137 #[doc(inline)]
138 pub use ruma_push_gateway_api as push_gateway;
139}
140
141#[doc(no_inline)]
142pub use assign::assign;
143#[doc(no_inline)]
144pub use js_int::{int, uint, Int, UInt};
145#[doc(no_inline)]
146pub use js_option::JsOption;
147#[cfg(feature = "client-ext-client-api")]
148pub use ruma_client::Client;
149pub use ruma_common::*;
150pub use web_time as time;