#[repr(C)]pub struct WasmSlice {
pub ptr: WasmWord,
pub len: WasmWord,
}Expand description
Fields§
§ptr: WasmWord§len: WasmWordImplementations§
Source§impl WasmSlice
impl WasmSlice
Sourcepub fn encode<'a, T: IntoWasmAbi + 'a>(
slice: &'a [T],
f: impl FnMut(&'a T) -> T::Abi,
) -> Self
pub fn encode<'a, T: IntoWasmAbi + 'a>( slice: &'a [T], f: impl FnMut(&'a T) -> T::Abi, ) -> Self
An encoded sequence: a fresh buffer of each element’s cell, its scalar
ABI by f, which JS decodes and frees.
Sourcepub unsafe fn try_decode<T: FromWasmAbi>(self) -> Result<Box<[T]>, &'static str>
pub unsafe fn try_decode<T: FromWasmAbi>(self) -> Result<Box<[T]>, &'static str>
Takes an encoded sequence from JS, converting each element from its
cell’s ABI with FromWasmAbi::try_from_abi. A rejected element stops
the decode, dropping the buffer and every element converted so far.
§Safety
self must be len cells of T::Abi that JS allocated at the cell’s
alignment, for Rust to own.
Trait Implementations§
impl Copy for WasmSlice
Auto Trait Implementations§
impl Freeze for WasmSlice
impl RefUnwindSafe for WasmSlice
impl Send for WasmSlice
impl Sync for WasmSlice
impl Unpin for WasmSlice
impl UnsafeUnpin for WasmSlice
impl UnwindSafe for WasmSlice
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> Upcast<T> for S
impl<S, T> Upcast<T> for S
Source§fn upcast(&self) -> &T
fn upcast(&self) -> &T
Perform a zero-cost type-safe upcast to a wider ref type within the Wasm
bindgen generics type system. Read more
Source§fn upcast_into(self) -> Twhere
Self: Sized + ErasableGeneric,
T: Sized + ErasableGeneric<Repr = <Self as ErasableGeneric>::Repr>,
fn upcast_into(self) -> Twhere
Self: Sized + ErasableGeneric,
T: Sized + ErasableGeneric<Repr = <Self as ErasableGeneric>::Repr>,
Perform a zero-cost type-safe upcast to a wider type within the Wasm
bindgen generics type system. Read more