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 serde;
36pub mod space;
37pub mod thirdparty;
38mod time;
39pub mod to_device;
40
41use std::fmt;
42
43#[cfg(feature = "canonical-json")]
44pub use self::canonical_json::{CanonicalJsonError, CanonicalJsonObject, CanonicalJsonValue};
45pub use self::{
46    identifiers::*,
47    time::{MilliSecondsSinceUnixEpoch, SecondsSinceUnixEpoch},
48};
49
50// Wrapper around `Box<str>` that cannot be used in a meaningful way outside of
51// this crate. Used for string enums because their `_Custom` variant can't be
52// truly private (only `#[doc(hidden)]`).
53#[doc(hidden)]
54#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
55pub struct PrivOwnedStr(Box<str>);
56
57impl fmt::Debug for PrivOwnedStr {
58    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
59        self.0.fmt(f)
60    }
61}
62
63/// Re-exports used by macro-generated code.
64///
65/// It is not considered part of this module's public API.
66#[doc(hidden)]
67pub mod exports {
68    #[cfg(feature = "api")]
69    pub use bytes;
70    #[cfg(feature = "api")]
71    pub use http;
72    pub use ruma_macros;
73    pub use serde;
74    pub use serde_html_form;
75    pub use serde_json;
76}