Skip to main content

FromFFIValue

Trait FromFFIValue 

Source
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§

Source

type Owned

The owned inner type.

Required Methods§

Source

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.

Source

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Creates Self::Inner from an owned value.

Provided Methods§

Source

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".

Implementations on Foreign Types§

Source§

impl<'a> FromFFIValue<'a> for bool

Available on non-substrate_runtime only.
Source§

type Owned = bool

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: u32) -> Result<bool>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for i8

Available on non-substrate_runtime only.
Source§

type Owned = i8

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: i32) -> Result<i8>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for i16

Available on non-substrate_runtime only.
Source§

type Owned = i16

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: i32) -> Result<i16>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for i32

Available on non-substrate_runtime only.
Source§

type Owned = i32

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: i32) -> Result<i32>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for i64

Available on non-substrate_runtime only.
Source§

type Owned = i64

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: i64) -> Result<i64>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for u8

Available on non-substrate_runtime only.
Source§

type Owned = u8

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: u32) -> Result<u8>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for u16

Available on non-substrate_runtime only.
Source§

type Owned = u16

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: u32) -> Result<u16>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for u32

Available on non-substrate_runtime only.
Source§

type Owned = u32

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: u32) -> Result<u32>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Source§

impl<'a> FromFFIValue<'a> for u64

Available on non-substrate_runtime only.
Source§

type Owned = u64

Source§

fn from_ffi_value(_: &mut dyn FunctionContext, arg: u64) -> Result<u64>

Source§

fn take_from_owned(owned: &'a mut Self::Owned) -> Self::Inner

Implementors§

Source§

impl<'a, T, U> FromFFIValue<'a> for PassAs<T, U>
where U: RIType + FromFFIValue<'a> + Primitive, T: TryFrom<<U as FromFFIValue<'a>>::Owned> + Copy,

Available on non-substrate_runtime only.
Source§

type Owned = T

Source§

impl<'a, T, const N: usize> FromFFIValue<'a> for PassPointerAndRead<&'a T, N>
where T: From<[u8; N]>,

Available on non-substrate_runtime only.
Source§

type Owned = T

Source§

impl<'a, T, const N: usize> FromFFIValue<'a> for PassPointerAndReadCopy<T, N>
where T: From<[u8; N]> + Copy,

Available on non-substrate_runtime only.
Source§

type Owned = T

Source§

impl<'a, T, const N: usize> FromFFIValue<'a> for PassPointerAndWrite<&'a mut T, N>
where T: Default + AsRef<[u8]>,

Available on non-substrate_runtime only.
Source§

type Owned = T

Source§

impl<'a, T: Decode> FromFFIValue<'a> for PassFatPointerAndDecode<T>

Available on non-substrate_runtime only.
Source§

impl<'a, T: Decode> FromFFIValue<'a> for PassFatPointerAndDecodeSlice<&'a [T]>

Available on non-substrate_runtime only.
Source§

type Owned = Vec<T>

Source§

impl<'a, T: PointerType> FromFFIValue<'a> for Pointer<T>

Available on non-substrate_runtime only.
Source§

impl<'a> FromFFIValue<'a> for PassFatPointerAndRead<&'a [u8]>

Available on non-substrate_runtime only.
Source§

impl<'a> FromFFIValue<'a> for PassFatPointerAndRead<&'a str>

Available on non-substrate_runtime only.
Source§

impl<'a> FromFFIValue<'a> for PassFatPointerAndRead<Vec<u8>>

Available on non-substrate_runtime only.
Source§

impl<'a> FromFFIValue<'a> for PassFatPointerAndReadOption<&'a [u8]>

Available on non-substrate_runtime only.
Source§

impl<'a> FromFFIValue<'a> for PassFatPointerAndReadWrite<&'a mut [u8]>

Available on non-substrate_runtime only.
Source§

impl<'a> FromFFIValue<'a> for PassFatPointerAndWrite<&'a mut [u8]>

Available on non-substrate_runtime only.