Trait wasmer::FromToNativeWasmType
source · pub unsafe trait FromToNativeWasmTypewhere
Self: Sized,{
type Native: NativeWasmTypeInto;
// Required methods
fn from_native(native: Self::Native) -> Self;
fn to_native(self) -> Self::Native;
// Provided method
fn is_from_store(&self, _store: &impl AsStoreRef) -> bool { ... }
}
Expand description
A trait to convert a Rust value to a WasmNativeType
value,
or to convert WasmNativeType
value to a Rust value.
This trait should ideally be split into two traits:
FromNativeWasmType
and ToNativeWasmType
but it creates a
non-negligible complexity in the WasmTypeList
implementation.
§Safety
This trait is unsafe given the nature of how values are written and read from the native stack
Required Associated Types§
sourcetype Native: NativeWasmTypeInto
type Native: NativeWasmTypeInto
Native Wasm type.
Required Methods§
sourcefn from_native(native: Self::Native) -> Self
fn from_native(native: Self::Native) -> Self
Convert a value of kind Self::Native
to Self
.
§Panics
This method panics if native
cannot fit in the Self
type`.
Provided Methods§
sourcefn is_from_store(&self, _store: &impl AsStoreRef) -> bool
fn is_from_store(&self, _store: &impl AsStoreRef) -> bool
Returns whether the given value is from the given store.
This always returns true for primitive types that can be used with any context.
Object Safety§
This trait is not object safe.