devela::_dep::js_sys::wasm_bindgen::convert

Trait LongRefFromWasmAbi

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

    // Required method
    unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor;
}
Available on crate feature dep_js_sys only.
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’.

§⚠️ Unstable

This is part of the internal convert module, no stability guarantees are provided. Use at your own risk. See its documentation for more details.

Required Associated Types§

Source

type Abi: WasmAbi

Same as RefFromWasmAbi::Abi

Source

type Anchor: Borrow<Self>

Same as RefFromWasmAbi::Anchor

Required Methods§

Source

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl LongRefFromWasmAbi for str

Source§

impl LongRefFromWasmAbi for [f32]

Source§

impl LongRefFromWasmAbi for [f64]

Source§

impl LongRefFromWasmAbi for [i8]

Source§

impl LongRefFromWasmAbi for [i16]

Source§

impl LongRefFromWasmAbi for [i32]

Source§

impl LongRefFromWasmAbi for [i64]

Source§

impl LongRefFromWasmAbi for [isize]

Source§

impl LongRefFromWasmAbi for [u8]

Source§

impl LongRefFromWasmAbi for [u16]

Source§

impl LongRefFromWasmAbi for [u32]

Source§

impl LongRefFromWasmAbi for [u64]

Source§

impl LongRefFromWasmAbi for [usize]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<f32>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<f64>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<i8>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<i16>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<i32>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<i64>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<isize>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<u8>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<u16>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<u32>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<u64>]

Source§

impl LongRefFromWasmAbi for [MaybeUninit<usize>]

Implementors§

Source§

impl LongRefFromWasmAbi for JsValue

Source§

impl LongRefFromWasmAbi for Collator

Source§

impl LongRefFromWasmAbi for DateTimeFormat

Source§

impl LongRefFromWasmAbi for NumberFormat

Source§

impl LongRefFromWasmAbi for PluralRules

Source§

impl LongRefFromWasmAbi for RelativeTimeFormat

Source§

impl LongRefFromWasmAbi for CompileError

Source§

impl LongRefFromWasmAbi for Exception

Source§

impl LongRefFromWasmAbi for Global

Source§

impl LongRefFromWasmAbi for Instance

Source§

impl LongRefFromWasmAbi for LinkError

Source§

impl LongRefFromWasmAbi for Memory

Source§

impl LongRefFromWasmAbi for Module

Source§

impl LongRefFromWasmAbi for RuntimeError

Source§

impl LongRefFromWasmAbi for Table

Source§

impl LongRefFromWasmAbi for Tag

Source§

impl LongRefFromWasmAbi for Array

Source§

impl LongRefFromWasmAbi for ArrayBuffer

Source§

impl LongRefFromWasmAbi for AsyncIterator

Source§

impl LongRefFromWasmAbi for BigInt64Array

Source§

impl LongRefFromWasmAbi for BigInt

Source§

impl LongRefFromWasmAbi for BigUint64Array

Source§

impl LongRefFromWasmAbi for Boolean

Source§

impl LongRefFromWasmAbi for DataView

Source§

impl LongRefFromWasmAbi for Date

Source§

impl LongRefFromWasmAbi for Error

Source§

impl LongRefFromWasmAbi for EvalError

Source§

impl LongRefFromWasmAbi for Float32Array

Source§

impl LongRefFromWasmAbi for Float64Array

Source§

impl LongRefFromWasmAbi for Function

Source§

impl LongRefFromWasmAbi for Generator

Source§

impl LongRefFromWasmAbi for Int8Array

Source§

impl LongRefFromWasmAbi for Int16Array

Source§

impl LongRefFromWasmAbi for Int32Array

Source§

impl LongRefFromWasmAbi for Iterator

Source§

impl LongRefFromWasmAbi for IteratorNext

Source§

impl LongRefFromWasmAbi for JsString

Source§

impl LongRefFromWasmAbi for Map

Source§

impl LongRefFromWasmAbi for Number

Source§

impl LongRefFromWasmAbi for Object

Source§

impl LongRefFromWasmAbi for Promise

Source§

impl LongRefFromWasmAbi for Proxy

Source§

impl LongRefFromWasmAbi for RangeError

Source§

impl LongRefFromWasmAbi for ReferenceError

Source§

impl LongRefFromWasmAbi for RegExp

Source§

impl LongRefFromWasmAbi for Set

Source§

impl LongRefFromWasmAbi for SharedArrayBuffer

Source§

impl LongRefFromWasmAbi for Symbol

Source§

impl LongRefFromWasmAbi for SyntaxError

Source§

impl LongRefFromWasmAbi for TypeError

Source§

impl LongRefFromWasmAbi for Uint8Array

Source§

impl LongRefFromWasmAbi for Uint8ClampedArray

Source§

impl LongRefFromWasmAbi for Uint16Array

Source§

impl LongRefFromWasmAbi for Uint32Array

Source§

impl LongRefFromWasmAbi for UriError

Source§

impl LongRefFromWasmAbi for WeakMap

Source§

impl LongRefFromWasmAbi for WeakSet