pub trait IntoPreallocatedFFIValue: RIType {
type SelfInstance;
// Required method
fn into_preallocated_ffi_value(
self_instance: Self::SelfInstance,
context: &mut dyn FunctionContext,
allocated: Self::FFIType,
) -> Result<()>;
}
Expand description
Something that can be converted into a preallocated ffi value.
Every type parameter that should be given as &mut
into a runtime interface function, needs
to implement this trait. After executing the host implementation of the runtime interface
function, the value is copied into the preallocated wasm memory.
This should only be used for types which have a fixed size, like slices. Other types like a vec do not work with this interface, as we can not call into wasm to reallocate memory. So, this trait should be implemented carefully.
Required Associated Types§
sourcetype SelfInstance
type SelfInstance
As Self
can be an unsized type, it needs to be represented by a sized type at the host.
This SelfInstance
is the sized type.
Required Methods§
sourcefn into_preallocated_ffi_value(
self_instance: Self::SelfInstance,
context: &mut dyn FunctionContext,
allocated: Self::FFIType,
) -> Result<()>
fn into_preallocated_ffi_value( self_instance: Self::SelfInstance, context: &mut dyn FunctionContext, allocated: Self::FFIType, ) -> Result<()>
Convert self_instance
into the given preallocated ffi value.
Object Safety§
This trait is not object safe.