pub trait FromFFIValue<'a>: RIType {
type Owned;
// Required methods
fn from_ffi_value(
context: &mut dyn FunctionContext,
arg: Self::FFIType,
) -> Result<Self::Owned>;
fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner;
// Provided method
fn write_back_into_runtime(
_value: Self::Owned,
_context: &mut dyn FunctionContext,
_arg: Self::FFIType,
) -> Result<()> { ... }
}
Expand description
A type used as a parameter in a host function. Can be created from an FFI value.
Implementations are safe to assume that the arg
given to from_ffi_value
is only generated by the corresponding wasm::IntoFFIValue
implementation.
Required Associated Types§
Required Methods§
Sourcefn from_ffi_value(
context: &mut dyn FunctionContext,
arg: Self::FFIType,
) -> Result<Self::Owned>
fn from_ffi_value( context: &mut dyn FunctionContext, arg: Self::FFIType, ) -> Result<Self::Owned>
Creates Self::Owned
from the given arg
received through the FFI boundary from the
runtime.
Sourcefn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner
fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner
Creates Self::Inner
from an owned value.
Provided Methods§
Sourcefn write_back_into_runtime(
_value: Self::Owned,
_context: &mut dyn FunctionContext,
_arg: Self::FFIType,
) -> Result<()>
fn write_back_into_runtime( _value: Self::Owned, _context: &mut dyn FunctionContext, _arg: Self::FFIType, ) -> Result<()>
Write back a modified value
back into the runtime’s memory.
Only makes sense for parameters like e.g. &mut [u8]
.
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.