ruma_common/
lib.rs

1#![doc(html_favicon_url = "https://ruma.dev/favicon.ico")]
2#![doc(html_logo_url = "https://ruma.dev/images/logo.png")]
3//! Common types for the Ruma crates.
4
5#![recursion_limit = "1024"]
6#![warn(missing_docs)]
7// https://github.com/rust-lang/rust-clippy/issues/9029
8#![allow(clippy::derive_partial_eq_without_eq)]
9#![cfg_attr(docsrs, feature(doc_auto_cfg))]
10
11#[cfg(not(all(feature = "client", feature = "server")))]
12compile_error!(
13    "ruma_common's `client` and `server` Cargo features only exist as a workaround are not meant to be disabled"
14);
15
16// Hack to allow both ruma-common itself and external crates (or tests) to use procedural macros
17// that expect `ruma_common` to exist in the prelude.
18extern crate self as ruma_common;
19
20#[cfg(feature = "api")]
21pub mod api;
22pub mod authentication;
23#[cfg(feature = "canonical-json")]
24pub mod canonical_json;
25pub mod directory;
26pub mod encryption;
27pub mod http_headers;
28mod identifiers;
29pub mod media;
30mod percent_encode;
31pub mod power_levels;
32pub mod presence;
33pub mod push;
34pub mod room;
35pub mod room_version_rules;
36pub mod serde;
37pub mod third_party_invite;
38pub mod thirdparty;
39mod time;
40pub mod to_device;
41
42use std::fmt;
43
44#[cfg(feature = "canonical-json")]
45pub use self::canonical_json::{CanonicalJsonError, CanonicalJsonObject, CanonicalJsonValue};
46pub use self::{
47    identifiers::*,
48    time::{MilliSecondsSinceUnixEpoch, SecondsSinceUnixEpoch},
49};
50
51// Wrapper around `Box<str>` that cannot be used in a meaningful way outside of
52// this crate. Used for string enums because their `_Custom` variant can't be
53// truly private (only `#[doc(hidden)]`).
54#[doc(hidden)]
55#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
56pub struct PrivOwnedStr(Box<str>);
57
58impl fmt::Debug for PrivOwnedStr {
59    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60        self.0.fmt(f)
61    }
62}
63
64/// Re-exports used by macro-generated code.
65///
66/// It is not considered part of this module's public API.
67#[doc(hidden)]
68pub mod exports {
69    #[cfg(feature = "api")]
70    pub use bytes;
71    #[cfg(feature = "api")]
72    pub use http;
73    pub use ruma_macros;
74    pub use serde;
75    pub use serde_html_form;
76    pub use serde_json;
77}