xmtp_common/
wasm.rs

1pub mod tokio {
2    pub mod task {
3        crate::if_native! {
4            pub use tokio::task::*;
5        }
6        crate::if_wasm! {
7            pub use tokio_with_wasm::task::*;
8        }
9    }
10}
11
12pub use tokio::*;
13
14crate::if_wasm! {
15    /// Marker trait to determine whether a type implements `Send` or not.
16    pub trait MaybeSend {}
17    impl<T: ?Sized> MaybeSend for T {}
18
19    /// Marker trait to determine whether a type implements `Send` or not.
20    pub trait MaybeSync {}
21    impl<T: ?Sized> MaybeSync for T {}
22
23    /// Global Marker trait for WebAssembly
24    pub trait Wasm {}
25    impl<T> Wasm for T {}
26
27    pub type BoxDynError = Box<dyn std::error::Error>;
28
29    pub use futures::future::LocalBoxFuture as BoxDynFuture;
30
31    pub use futures::stream::LocalBoxStream as BoxDynStream;
32
33}
34
35crate::if_native! {
36    /// Marker trait to determine whether a type implements `Send` or not.
37    pub trait MaybeSend: Send {}
38    impl<T: Send + ?Sized> MaybeSend for T {}
39
40    /// Marker trait to determine whether a type implements `Sync` or not.
41    pub trait MaybeSync: Sync {}
42    impl<T: Sync + ?Sized> MaybeSync for T {}
43
44    pub type BoxDynError = Box<dyn std::error::Error + Send + Sync>;
45
46    pub use futures::future::BoxFuture as BoxDynFuture;
47
48    pub use futures::stream::BoxStream as BoxDynStream;
49
50}
51
52pub trait MaybeSendFuture: Future + MaybeSend {}
53impl<T: Future + MaybeSend> MaybeSendFuture for T {}