host.rs (1310B)
1 //! Target-aware host bounds and shared handles for transport composition. 2 3 /// Concrete WebSocket I/O supplied by native or browser hosts. 4 #[cfg(feature = "std")] 5 pub mod websocket; 6 7 /// Native host implementations are thread safe; browser hosts may be local. 8 #[cfg(not(target_arch = "wasm32"))] 9 pub trait HostBound: Send + Sync {} 10 #[cfg(not(target_arch = "wasm32"))] 11 impl<T: Send + Sync + ?Sized> HostBound for T {} 12 /// Native host implementations are thread safe; browser hosts may be local. 13 #[cfg(target_arch = "wasm32")] 14 pub trait HostBound {} 15 #[cfg(target_arch = "wasm32")] 16 impl<T: ?Sized> HostBound for T {} 17 18 /// Native subscription ownership may move between threads. 19 #[cfg(not(target_arch = "wasm32"))] 20 pub trait MoveBound: Send {} 21 #[cfg(not(target_arch = "wasm32"))] 22 impl<T: Send + ?Sized> MoveBound for T {} 23 /// Browser subscription ownership remains local to its host. 24 #[cfg(target_arch = "wasm32")] 25 pub trait MoveBound {} 26 #[cfg(target_arch = "wasm32")] 27 impl<T: ?Sized> MoveBound for T {} 28 29 /// Shared host ownership. Browser handles never require an unsafe Send bridge. 30 #[cfg(not(target_arch = "wasm32"))] 31 pub type Shared<T> = alloc::sync::Arc<T>; 32 /// Shared host ownership. Browser handles never require an unsafe Send bridge. 33 #[cfg(target_arch = "wasm32")] 34 pub type Shared<T> = alloc::rc::Rc<T>;