7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | // Copyright 2022 The Matrix.org Foundation C.I.C. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | // you may not use this file except in compliance with the License. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | // You may obtain a copy of the License at |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | // Unless required by applicable law or agreed to in writing, software |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | // See the License for the specific language governing permissions and |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | // limitations under the License. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | #![doc = include_str!("../README.md")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | #![warn(missing_debug_implementations)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | use std::pin::Pin; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | use ruma::{RoomVersionId, room_version_rules::RoomVersionRules}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | #[cfg(test)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | matrix_sdk_test_utils::init_tracing_for_tests!(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | use futures_core::Future; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | #[doc(no_inline)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | pub use ruma; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | pub mod cross_process_lock; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | pub mod debug; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | pub mod deserialized_responses; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | mod edit_validation; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | pub mod executor; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | pub mod failures_cache; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | pub mod linked_chunk; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | pub mod locks; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | pub mod ring_buffer; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | pub mod serde_helpers; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | pub mod sleep; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | pub mod stream; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | pub mod task_monitor; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | pub mod timeout; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | pub mod tracing_timer; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | pub mod ttl; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | // We cannot currently measure test coverage in the WASM environment, so |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | // js_tracing is incorrectly flagged as untested. Disable coverage checking for |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | // it. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | #[cfg(all(target_family = "wasm", not(tarpaulin_include)))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | pub mod js_tracing; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 51 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 52 | pub use cross_process_lock::LEASE_DURATION_MS; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 53 | pub use edit_validation::*; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 54 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 55 | /// Alias for `Send` on non-wasm, empty trait (implemented by everything) on |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 56 | /// wasm. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 57 | #[cfg(not(target_family = "wasm"))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 58 | pub trait SendOutsideWasm: Send {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 59 | #[cfg(not(target_family = "wasm"))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 60 | impl<T: Send> SendOutsideWasm for T {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 61 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 62 | /// Alias for `Send` on non-wasm, empty trait (implemented by everything) on |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 63 | /// wasm. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 64 | #[cfg(target_family = "wasm")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 65 | pub trait SendOutsideWasm {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 66 | #[cfg(target_family = "wasm")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 67 | impl<T> SendOutsideWasm for T {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 68 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 69 | /// Alias for `Sync` on non-wasm, empty trait (implemented by everything) on |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 70 | /// wasm. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 71 | #[cfg(not(target_family = "wasm"))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 72 | pub trait SyncOutsideWasm: Sync {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 73 | #[cfg(not(target_family = "wasm"))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 74 | impl<T: Sync> SyncOutsideWasm for T {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 75 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 76 | /// Alias for `Sync` on non-wasm, empty trait (implemented by everything) on |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 77 | /// wasm. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 78 | #[cfg(target_family = "wasm")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 79 | pub trait SyncOutsideWasm {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 80 | #[cfg(target_family = "wasm")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 81 | impl<T> SyncOutsideWasm for T {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 82 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 83 | /// Super trait that is used for our store traits, this trait will differ if |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 84 | /// it's used on WASM. WASM targets will not require `Send` and `Sync` to have |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 85 | /// implemented, while other targets will. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 86 | pub trait AsyncTraitDeps: std::fmt::Debug + SendOutsideWasm + SyncOutsideWasm {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 87 | impl<T: std::fmt::Debug + SendOutsideWasm + SyncOutsideWasm> AsyncTraitDeps for T {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 88 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 89 | // TODO: Remove in favor of impl Trait once allowed in associated types |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 90 | #[macro_export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 91 | macro_rules! boxed_into_future { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 92 | () => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 93 | $crate::boxed_into_future!(extra_bounds: ); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 94 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 95 | (extra_bounds: $($extra_bounds:tt)*) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 96 | #[cfg(target_family = "wasm")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 97 | type IntoFuture = ::std::pin::Pin<::std::boxed::Box< |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 98 | dyn ::std::future::Future<Output = Self::Output> + $($extra_bounds)* |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 99 | >>; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 100 | #[cfg(not(target_family = "wasm"))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 101 | type IntoFuture = ::std::pin::Pin<::std::boxed::Box< |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 102 | dyn ::std::future::Future<Output = Self::Output> + Send + $($extra_bounds)* |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 103 | >>; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 104 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 105 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 106 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 107 | /// A `Box::pin` future that is `Send` on non-wasm, and without `Send` on wasm. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 108 | #[cfg(target_family = "wasm")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 109 | pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a>>; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 110 | #[cfg(not(target_family = "wasm"))] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 111 | pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 112 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 113 | #[cfg(feature = "uniffi")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 114 | uniffi::setup_scaffolding!(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 115 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 116 | /// The room version to use as a fallback when the version of a room is unknown. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 117 | pub const ROOM_VERSION_FALLBACK: RoomVersionId = RoomVersionId::V11; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 118 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 119 | /// The room version rules to use as a fallback when the version of a room is |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 120 | /// unknown or unsupported. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 121 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 122 | /// These are the rules of the [`ROOM_VERSION_FALLBACK`]. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 123 | pub const ROOM_VERSION_RULES_FALLBACK: RoomVersionRules = RoomVersionRules::V11; |