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 features
33//!
34//! By default, the ruma crates are only able to handle strictly spec-compliant data and behaviour.
35//! However, due to the fact that Matrix is federated, that it is used by various implementations
36//! that might have different bugs, and that much of its data is immutable, they need to be able to
37//! interoperate with data that might differ slightly from the specification.
38//!
39//! This is the role of the `compat-*` cargo features. They allow the crates be more tolerant of
40//! external data and incoming requests for known and reasonable deviations from the spec, usually
41//! for historical reasons. They however do not permit the ruma crates to generate data that is not
42//! spec-compliant.
43//!
44//! Each cargo feature is documented briefly in the cargo manifest of the crate, and more thoroughly
45//! where the feature applies.
46//!
47//! # Convenience features
48//!
49//! These features are only useful if you want to use a method that requires it:
50//!
51//! * `rand` -- Generate random identifiers.
52//! * `markdown` -- Parse markdown to construct messages.
53//! * `html` -- Parse HTML to sanitize it or navigate its tree.
54//! * `html-matrix` -- Enables the `matrix` feature of `ruma-html` to parse HTML elements data to
55//! typed data as suggested by the Matrix Specification.
56//!
57//! # Unstable features
58//!
59//! By using these features, you opt out of all semver guarantees Ruma otherwise provides:
60//!
61//! * `unstable-mscXXXX`, where `XXXX` is the MSC number -- Upcoming Matrix features that may be
62//! subject to change or removal.
63//!
64//! # Common features
65//!
66//! These submodules are usually activated by the API features when needed:
67//!
68//! * `api`
69//! * `events`
70//! * `signatures`
71//!
72//! # Compile-time `cfg` settings
73//!
74//! These settings are accepted at compile time to configure the generated code. They can be set as
75//! `--cfg={key}={value}` using `RUSTFLAGS` or `.cargo/config.toml` (under `[build]` -> `rustflags =
76//! ["..."]`). They can also be configured using an environment variable at compile time, which has
77//! the benefit of not requiring to re-compile the whole dependency chain when their value is
78//! changed.
79//!
80//! * `ruma_identifiers_storage` -- Choose the inner representation of `Owned*` wrapper types for
81//! identifiers. By default they use [`Box`], setting the value to `Arc` makes them use
82//! [`Arc`](std::sync::Arc). This can also be configured by setting the `RUMA_IDENTIFIERS_STORAGE`
83//! environment variable.
84//! * `ruma_unstable_exhaustive_types` -- Most types in Ruma are marked as non-exhaustive to avoid
85//! breaking changes when new fields are added in the specification. This setting compiles all
86//! types as exhaustive. By enabling this feature you opt out of all semver guarantees Ruma
87//! otherwise provides. This can also be configured by setting the
88//! `RUMA_UNSTABLE_EXHAUSTIVE_TYPES` environment variable.
89
90#![warn(missing_docs)]
91#![cfg_attr(docsrs, feature(doc_auto_cfg))]
92
93#[cfg(feature = "events")]
94#[doc(inline)]
95pub use ruma_events as events;
96#[cfg(feature = "html")]
97#[doc(inline)]
98pub use ruma_html as html;
99#[cfg(feature = "signatures")]
100#[doc(inline)]
101pub use ruma_signatures as signatures;
102#[cfg(feature = "state-res")]
103#[doc(inline)]
104pub use ruma_state_res as state_res;
105
106/// (De)serializable types for various [Matrix APIs][apis] requests and responses and abstractions
107/// for them.
108///
109/// [apis]: https://spec.matrix.org/latest/#matrix-apis
110#[cfg(feature = "api")]
111pub mod api {
112 #[cfg(any(feature = "appservice-api-c", feature = "appservice-api-s"))]
113 #[doc(inline)]
114 pub use ruma_appservice_api as appservice;
115 #[cfg(any(feature = "client-api-c", feature = "client-api-s"))]
116 #[doc(inline)]
117 pub use ruma_client_api as client;
118 // The metadata macro is also exported at the crate root because `#[macro_export]` always
119 // places things at the crate root of the defining crate and we do a glob re-export of
120 // `ruma_common`, but here is the more logical (preferred) location.
121 pub use ruma_common::{api::*, metadata};
122 #[cfg(any(feature = "federation-api-c", feature = "federation-api-s"))]
123 #[doc(inline)]
124 pub use ruma_federation_api as federation;
125 #[cfg(any(feature = "identity-service-api-c", feature = "identity-service-api-s"))]
126 #[doc(inline)]
127 pub use ruma_identity_service_api as identity_service;
128 #[cfg(any(feature = "push-gateway-api-c", feature = "push-gateway-api-s"))]
129 #[doc(inline)]
130 pub use ruma_push_gateway_api as push_gateway;
131}
132
133#[doc(no_inline)]
134pub use assign::assign;
135#[doc(no_inline)]
136pub use js_int::{int, uint, Int, UInt};
137#[doc(no_inline)]
138pub use js_option::JsOption;
139pub use ruma_common::*;
140pub use web_time as time;