Trait VectorRefIntoWasmAbi
pub trait VectorRefIntoWasmAbi
Internal trait used by the slice_to_array macro codegen.
Produces the wire representation JS observes when an outgoing &[T]
argument is rendered as a plain Array. There are two impl shapes,
neither of which requires T: Clone:
- For primitive numeric
T(u8,i32,f64, ...) the wire is a borrow of the slice memory directly — no allocation, no copy. The JS-side shim performsArray.from(typedArrayView)to materialise the JSArrayand never frees the buffer. - For everything else (
String,JsValue, imported types, exported types) the wire is a freshly allocatedBox<[u32]>of externref indices — one per element, constructed via&T -> JsValue(which for handle-shaped types is a refcount bump on the existing JS slot, and forString/ value-shaped types creates a fresh JS value). The JS-side shim reads the indices into a JSArrayand frees the index buffer.
Both shapes carry the same WasmSlice (ptr + len) on the wire. The
cli-support side picks the right JS shim based on the element
VectorKind recovered from the descriptor.
Not user-facing: users opt in via #[wasm_bindgen(slice_to_array)]
on an imported function or extern "C" block.
Required Methods
fn slice_into_abi(slice: &[Self]) -> WasmSlice where Self: Sized,Construct the wire representation for
Some(slice). The returnedWasmSliceis either a borrow of the input slice (primitive case) or a buffer JS owns and frees (handle-shaped case).
Provided Methods
fn slice_none() -> WasmSlice where Self: Sized,Wire representation for
None(used byOption<&[T]>). A nullWasmSlice(ptr == 0) is the convention shared with every other vector-like ABI in the crate.
Implementors
impl VectorRefIntoWasmAbi for f32impl VectorRefIntoWasmAbi for f64impl VectorRefIntoWasmAbi for i16impl VectorRefIntoWasmAbi for i32impl VectorRefIntoWasmAbi for i64impl VectorRefIntoWasmAbi for i8impl VectorRefIntoWasmAbi for isizeimpl VectorRefIntoWasmAbi for u16impl VectorRefIntoWasmAbi for u32impl VectorRefIntoWasmAbi for u64impl VectorRefIntoWasmAbi for u8impl VectorRefIntoWasmAbi for usizeimpl<T> VectorRefIntoWasmAbi for JsNullable<T> where &'a T: for<'a> Into<JsValue>,impl<T> VectorRefIntoWasmAbi for JsOption<T> where &'a T: for<'a> Into<JsValue>,impl<T> VectorRefIntoWasmAbi for JsValue where &'a T: for<'a> Into<JsValue>,impl<T> VectorRefIntoWasmAbi for Null where &'a T: for<'a> Into<JsValue>,impl<T> VectorRefIntoWasmAbi for T where for<'a> &'a T: Into<JsValue>,impl<T> VectorRefIntoWasmAbi for Undefined where &'a T: for<'a> Into<JsValue>,