pub trait IntoWasmAbi: WasmDescribe {
type Abi: WasmAbi;
// Required method
fn into_abi(self) -> Self::Abi;
}Expand description
A trait for anything that can be converted into a type that can cross the
Wasm ABI directly, eg u32 or f64.
This is the opposite operation as FromWasmAbi and Ref[Mut]FromWasmAbi.
§⚠️ 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§
Required Methods§
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 IntoWasmAbi for Option<f64>
impl IntoWasmAbi for Option<f64>
Source§impl IntoWasmAbi for Option<i64>
impl IntoWasmAbi for Option<i64>
Source§impl IntoWasmAbi for Option<i128>
impl IntoWasmAbi for Option<i128>
Source§impl IntoWasmAbi for Option<u64>
impl IntoWasmAbi for Option<u64>
Source§impl IntoWasmAbi for Option<u128>
impl IntoWasmAbi for Option<u128>
Source§impl IntoWasmAbi for String
impl IntoWasmAbi for String
Source§impl<'a> IntoWasmAbi for &'a str
impl<'a> IntoWasmAbi for &'a str
Source§impl<'a> IntoWasmAbi for &'a [f32]
impl<'a> IntoWasmAbi for &'a [f32]
Source§impl<'a> IntoWasmAbi for &'a [f64]
impl<'a> IntoWasmAbi for &'a [f64]
Source§impl<'a> IntoWasmAbi for &'a [i8]
impl<'a> IntoWasmAbi for &'a [i8]
Source§impl<'a> IntoWasmAbi for &'a [i16]
impl<'a> IntoWasmAbi for &'a [i16]
Source§impl<'a> IntoWasmAbi for &'a [i32]
impl<'a> IntoWasmAbi for &'a [i32]
Source§impl<'a> IntoWasmAbi for &'a [i64]
impl<'a> IntoWasmAbi for &'a [i64]
Source§impl<'a> IntoWasmAbi for &'a [isize]
impl<'a> IntoWasmAbi for &'a [isize]
Source§impl<'a> IntoWasmAbi for &'a [u8]
impl<'a> IntoWasmAbi for &'a [u8]
Source§impl<'a> IntoWasmAbi for &'a [u16]
impl<'a> IntoWasmAbi for &'a [u16]
Source§impl<'a> IntoWasmAbi for &'a [u32]
impl<'a> IntoWasmAbi for &'a [u32]
Source§impl<'a> IntoWasmAbi for &'a [u64]
impl<'a> IntoWasmAbi for &'a [u64]
Source§impl<'a> IntoWasmAbi for &'a [usize]
impl<'a> IntoWasmAbi for &'a [usize]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<f32>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<f32>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<f64>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<f64>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<i8>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<i8>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<i16>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<i16>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<i32>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<i32>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<i64>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<i64>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<isize>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<isize>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<u8>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<u8>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<u16>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<u16>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<u32>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<u32>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<u64>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<u64>]
Source§impl<'a> IntoWasmAbi for &'a [MaybeUninit<usize>]
impl<'a> IntoWasmAbi for &'a [MaybeUninit<usize>]
Source§impl<'a> IntoWasmAbi for &'a mut [f32]
impl<'a> IntoWasmAbi for &'a mut [f32]
Source§impl<'a> IntoWasmAbi for &'a mut [f64]
impl<'a> IntoWasmAbi for &'a mut [f64]
Source§impl<'a> IntoWasmAbi for &'a mut [i8]
impl<'a> IntoWasmAbi for &'a mut [i8]
Source§impl<'a> IntoWasmAbi for &'a mut [i16]
impl<'a> IntoWasmAbi for &'a mut [i16]
Source§impl<'a> IntoWasmAbi for &'a mut [i32]
impl<'a> IntoWasmAbi for &'a mut [i32]
Source§impl<'a> IntoWasmAbi for &'a mut [i64]
impl<'a> IntoWasmAbi for &'a mut [i64]
Source§impl<'a> IntoWasmAbi for &'a mut [isize]
impl<'a> IntoWasmAbi for &'a mut [isize]
Source§impl<'a> IntoWasmAbi for &'a mut [u8]
impl<'a> IntoWasmAbi for &'a mut [u8]
Source§impl<'a> IntoWasmAbi for &'a mut [u16]
impl<'a> IntoWasmAbi for &'a mut [u16]
Source§impl<'a> IntoWasmAbi for &'a mut [u32]
impl<'a> IntoWasmAbi for &'a mut [u32]
Source§impl<'a> IntoWasmAbi for &'a mut [u64]
impl<'a> IntoWasmAbi for &'a mut [u64]
Source§impl<'a> IntoWasmAbi for &'a mut [usize]
impl<'a> IntoWasmAbi for &'a mut [usize]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<f32>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<f32>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<f64>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<f64>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i8>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i8>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i16>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i16>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i32>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i32>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i64>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<i64>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<isize>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<isize>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u8>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u8>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u16>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u16>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u32>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u32>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u64>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<u64>]
Source§impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<usize>]
impl<'a> IntoWasmAbi for &'a mut [MaybeUninit<usize>]
Source§impl<A, B, C, D, E, F, G, H, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E, F, G, H) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, F, G, H, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E, F, G, H) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, E, F, G, H, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E, F, G, H) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, F, G, H, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E, F, G, H) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, E, F, G, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E, F, G) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, F, G, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E, F, G) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, E, F, G, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E, F, G) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, F, G, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E, F, G) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, E, F, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E, F) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, F, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E, F) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, E, F, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E, F) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, F, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E, F) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, E, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, R> IntoWasmAbi for &(dyn Fn(A, B, C, D, E) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, E, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, E, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D, E) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, R> IntoWasmAbi for &(dyn Fn(A, B, C, D) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, R> IntoWasmAbi for &(dyn Fn(A, B, C, D) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, D, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, D, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C, D) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, R> IntoWasmAbi for &(dyn Fn(A, B, C) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, R> IntoWasmAbi for &(dyn Fn(A, B, C) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, C, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C) -> R + '_)where
Self: WasmDescribe,
impl<A, B, C, R> IntoWasmAbi for &mut (dyn FnMut(A, B, C) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, R> IntoWasmAbi for &(dyn Fn(A, B) -> R + '_)where
Self: WasmDescribe,
impl<A, B, R> IntoWasmAbi for &(dyn Fn(A, B) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, B, R> IntoWasmAbi for &mut (dyn FnMut(A, B) -> R + '_)where
Self: WasmDescribe,
impl<A, B, R> IntoWasmAbi for &mut (dyn FnMut(A, B) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, R> IntoWasmAbi for &(dyn Fn(&A) -> R + '_)where
Self: WasmDescribe,
impl<A, R> IntoWasmAbi for &(dyn Fn(&A) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, R> IntoWasmAbi for &(dyn Fn(A) -> R + '_)where
Self: WasmDescribe,
impl<A, R> IntoWasmAbi for &(dyn Fn(A) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, R> IntoWasmAbi for &mut (dyn FnMut(&A) -> R + '_)where
Self: WasmDescribe,
impl<A, R> IntoWasmAbi for &mut (dyn FnMut(&A) -> R + '_)where
Self: WasmDescribe,
Source§impl<A, R> IntoWasmAbi for &mut (dyn FnMut(A) -> R + '_)where
Self: WasmDescribe,
impl<A, R> IntoWasmAbi for &mut (dyn FnMut(A) -> R + '_)where
Self: WasmDescribe,
Source§impl<R> IntoWasmAbi for &(dyn Fn() -> R + '_)where
Self: WasmDescribe,
impl<R> IntoWasmAbi for &(dyn Fn() -> R + '_)where
Self: WasmDescribe,
Source§impl<R> IntoWasmAbi for &mut (dyn FnMut() -> R + '_)where
Self: WasmDescribe,
impl<R> IntoWasmAbi for &mut (dyn FnMut() -> R + '_)where
Self: WasmDescribe,
Source§impl<T> IntoWasmAbi for Vec<T>
impl<T> IntoWasmAbi for Vec<T>
Source§impl<T: ErasableGeneric<Repr = JsValue> + WasmDescribe> IntoWasmAbi for &[T]
impl<T: ErasableGeneric<Repr = JsValue> + WasmDescribe> IntoWasmAbi for &[T]
Source§impl<T: OptionIntoWasmAbi> IntoWasmAbi for Option<T>
impl<T: OptionIntoWasmAbi> IntoWasmAbi for Option<T>
Source§impl<T: VectorIntoWasmAbi> IntoWasmAbi for Box<[T]>
impl<T: VectorIntoWasmAbi> IntoWasmAbi for Box<[T]>
Implementors§
Source§impl IntoWasmAbi for JsError
impl IntoWasmAbi for JsError
Source§impl IntoWasmAbi for Null
impl IntoWasmAbi for Null
Source§impl IntoWasmAbi for Undefined
impl IntoWasmAbi for Undefined
Source§impl<'a> IntoWasmAbi for &'a Null
impl<'a> IntoWasmAbi for &'a Null
Source§impl<'a> IntoWasmAbi for &'a Undefined
impl<'a> IntoWasmAbi for &'a Undefined
Source§impl<'a, T> IntoWasmAbi for &'a JsOption<T>
impl<'a, T> IntoWasmAbi for &'a JsOption<T>
Source§impl<T> IntoWasmAbi for &ScopedClosure<'_, T>where
T: WasmClosure + ?Sized,
impl<T> IntoWasmAbi for &ScopedClosure<'_, T>where
T: WasmClosure + ?Sized,
Source§impl<T> IntoWasmAbi for ScopedClosure<'static, T>where
T: WasmClosure + ?Sized,
'static closures can be passed by value to JS, transferring ownership.
impl<T> IntoWasmAbi for ScopedClosure<'static, T>where
T: WasmClosure + ?Sized,
'static closures can be passed by value to JS, transferring ownership.
This is useful for one-shot callbacks where you want JS to own the closure. The closure will be cleaned up by JS GC (if weak references are supported) or will leak (if weak references are not supported).
§Example
ⓘ
#[wasm_bindgen]
extern "C" {
fn set_one_shot_callback(cb: Closure<dyn FnMut()>);
}
let cb = Closure::new(|| { /* ... */ });
set_one_shot_callback(cb); // Ownership transferred to JS
// No need to store or forget the closure