diff --git a/crates/matrix-sdk-common/src/lib.rs b/crates/matrix-sdk-common/src/lib.rs index 0f5213499..687e0ee13 100644 --- a/crates/matrix-sdk-common/src/lib.rs +++ b/crates/matrix-sdk-common/src/lib.rs @@ -8,18 +8,36 @@ pub mod executor; pub mod locks; pub mod timeout; -/// Super trait that is used for our store traits, this trait will differ if -/// it's used on WASM. WASM targets will not require `Send` and `Sync` to have -/// implemented, while other targets will. +/// Alias for `Send` on non-wasm, empty trait (implemented by everything) on +/// wasm. #[cfg(not(target_arch = "wasm32"))] -pub trait AsyncTraitDeps: std::fmt::Debug + Send + Sync {} +pub trait SendOutsideWasm: Send {} #[cfg(not(target_arch = "wasm32"))] -impl AsyncTraitDeps for T {} +impl SendOutsideWasm for T {} + +/// Alias for `Send` on non-wasm, empty trait (implemented by everything) on +/// wasm. +#[cfg(target_arch = "wasm32")] +pub trait SendOutsideWasm {} +#[cfg(target_arch = "wasm32")] +impl SendOutsideWasm for T {} + +/// Alias for `Sync` on non-wasm, empty trait (implemented by everything) on +/// wasm. +#[cfg(not(target_arch = "wasm32"))] +pub trait SyncOutsideWasm: Sync {} +#[cfg(not(target_arch = "wasm32"))] +impl SyncOutsideWasm for T {} + +/// Alias for `Sync` on non-wasm, empty trait (implemented by everything) on +/// wasm. +#[cfg(target_arch = "wasm32")] +pub trait SyncOutsideWasm {} +#[cfg(target_arch = "wasm32")] +impl SyncOutsideWasm for T {} /// Super trait that is used for our store traits, this trait will differ if /// it's used on WASM. WASM targets will not require `Send` and `Sync` to have /// implemented, while other targets will. -#[cfg(target_arch = "wasm32")] -pub trait AsyncTraitDeps: std::fmt::Debug {} -#[cfg(target_arch = "wasm32")] -impl AsyncTraitDeps for T {} +pub trait AsyncTraitDeps: std::fmt::Debug + SendOutsideWasm + SyncOutsideWasm {} +impl AsyncTraitDeps for T {}