pub trait LongRefFromWasmAbi: WasmDescribe {
    type Abi: WasmAbi;
    type Anchor: Borrow<Self>;

    unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor;
}
Expand description

A version of the RefFromWasmAbi trait with the additional requirement that the reference must remain valid as long as the anchor isn’t dropped.

This isn’t the case for JsValue’s RefFromWasmAbi implementation. To avoid having to allocate a spot for the JsValue on the JsValue heap, the JsValue is instead pushed onto the JsValue stack, and popped off again after the function that the reference was passed to returns. So, JsValue has a different LongRefFromWasmAbi implementation that behaves the same as FromWasmAbi, putting the value on the heap.

This is needed for async functions, where the reference needs to be valid for the whole length of the Future, rather than the initial synchronous call.

‘long ref’ is short for ‘long-lived reference’.

Required Associated Types§

Same as RefFromWasmAbi::Abi

Same as RefFromWasmAbi::Anchor

Required Methods§

Same as RefFromWasmAbi::ref_from_abi

Implementations on Foreign Types§

Implementors§