pub struct WasmSend<T>(/* private fields */);Expand description
Wrapper that unconditionally implements Send on WASM.
On native, WasmSend<T> is Send only if T: Send (no magic).
On WASM, WasmSend<T> is always Send, allowing !Send types
(like Writer wrapping a JsValue-backed response stream) to be
moved into a Web Worker.
§Safety contract
The caller must ensure that:
- The wrapped value is not actively used across threads simultaneously.
- When transferring to a Web Worker, any
!SendJS-backed values inside must beNone/uninitialized at transfer time and only populated inside the target worker (where JS objects belong to the local context).
FileDownloader satisfies this: writer is None when moved to the
Worker, and ensure_writer() creates the HTTP stream inside the Worker.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for WasmSend<T>where
T: Freeze,
impl<T> RefUnwindSafe for WasmSend<T>where
T: RefUnwindSafe,
impl<T> Sync for WasmSend<T>where
T: Sync,
impl<T> Unpin for WasmSend<T>where
T: Unpin,
impl<T> UnsafeUnpin for WasmSend<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for WasmSend<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more