pub trait WasmTypeListwhere
Self: Sized,{
type CStruct;
type Array: AsMut<[RawValue]>;
// Required methods
fn size() -> u32;
unsafe fn from_array(
store: &mut impl AsStoreMut,
array: Self::Array,
) -> Self;
unsafe fn from_slice(
store: &mut impl AsStoreMut,
slice: &[RawValue],
) -> Result<Self, TryFromSliceError>;
unsafe fn into_array(self, store: &mut impl AsStoreMut) -> Self::Array;
fn empty_array() -> Self::Array;
unsafe fn from_c_struct(
store: &mut impl AsStoreMut,
c_struct: Self::CStruct,
) -> Self;
unsafe fn into_c_struct(self, store: &mut impl AsStoreMut) -> Self::CStruct;
unsafe fn write_c_struct_to_ptr(c_struct: Self::CStruct, ptr: *mut RawValue);
fn wasm_types() -> &'static [Type];
}
Expand description
The WasmTypeList
trait represents a tuple (list) of Wasm
typed values. It is used to get low-level representation of
such a tuple.
Required Associated Types§
Required Methods§
Sourceunsafe fn from_array(store: &mut impl AsStoreMut, array: Self::Array) -> Self
unsafe fn from_array(store: &mut impl AsStoreMut, array: Self::Array) -> Self
Constructs Self
based on an array of values.
§Safety
Sourceunsafe fn from_slice(
store: &mut impl AsStoreMut,
slice: &[RawValue],
) -> Result<Self, TryFromSliceError>
unsafe fn from_slice( store: &mut impl AsStoreMut, slice: &[RawValue], ) -> Result<Self, TryFromSliceError>
Constructs Self
based on a slice of values.
from_slice
returns a Result
because it is possible
that the slice doesn’t have the same size than
Self::Array
, in which circumstance an error of kind
TryFromSliceError
will be returned.
§Safety
Sourceunsafe fn into_array(self, store: &mut impl AsStoreMut) -> Self::Array
unsafe fn into_array(self, store: &mut impl AsStoreMut) -> Self::Array
Builds and returns an array of type Array
from a tuple
(list) of values.
§Safety
Sourcefn empty_array() -> Self::Array
fn empty_array() -> Self::Array
Allocates and return an empty array of type Array
that
will hold a tuple (list) of values, usually to hold the
returned values of a WebAssembly function call.
Sourceunsafe fn from_c_struct(
store: &mut impl AsStoreMut,
c_struct: Self::CStruct,
) -> Self
unsafe fn from_c_struct( store: &mut impl AsStoreMut, c_struct: Self::CStruct, ) -> Self
Builds a tuple (list) of values from a C struct of type
CStruct
.
§Safety
Sourceunsafe fn into_c_struct(self, store: &mut impl AsStoreMut) -> Self::CStruct
unsafe fn into_c_struct(self, store: &mut impl AsStoreMut) -> Self::CStruct
Builds and returns a C struct of type CStruct
from a
tuple (list) of values.
§Safety
Sourceunsafe fn write_c_struct_to_ptr(c_struct: Self::CStruct, ptr: *mut RawValue)
unsafe fn write_c_struct_to_ptr(c_struct: Self::CStruct, ptr: *mut RawValue)
Writes the contents of a C struct to an array of RawValue
.
§Safety
Sourcefn wasm_types() -> &'static [Type]
fn wasm_types() -> &'static [Type]
Get the Wasm types for the tuple (list) of currently represented values.
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.