nectar_primitives/store/maybe_send.rs
1//! `Send`/`Sync` on native, unbounded on wasm32.
2
3/// `Send` on native targets, no bound on wasm32. The browser executor is
4/// single-threaded, so a getter future holding a JS handle across an await
5/// point is `!Send` there and must still satisfy the store traits.
6#[cfg(not(target_arch = "wasm32"))]
7pub trait MaybeSend: Send {}
8#[cfg(not(target_arch = "wasm32"))]
9impl<T: ?Sized + Send> MaybeSend for T {}
10
11/// `Send` on native targets, no bound on wasm32. The browser executor is
12/// single-threaded, so a getter future holding a JS handle across an await
13/// point is `!Send` there and must still satisfy the store traits.
14#[cfg(target_arch = "wasm32")]
15pub trait MaybeSend {}
16#[cfg(target_arch = "wasm32")]
17impl<T: ?Sized> MaybeSend for T {}
18
19/// `Sync` on native targets, no bound on wasm32. A browser store holding
20/// JS handles is `!Sync`; on the single-threaded wasm executor that is sound.
21#[cfg(not(target_arch = "wasm32"))]
22pub trait MaybeSync: Sync {}
23#[cfg(not(target_arch = "wasm32"))]
24impl<T: ?Sized + Sync> MaybeSync for T {}
25
26/// `Sync` on native targets, no bound on wasm32. A browser store holding
27/// JS handles is `!Sync`; on the single-threaded wasm executor that is sound.
28#[cfg(target_arch = "wasm32")]
29pub trait MaybeSync {}
30#[cfg(target_arch = "wasm32")]
31impl<T: ?Sized> MaybeSync for T {}