sp_runtime_interface

Trait RIType

Source
pub trait RIType {
    type FFIType: IntoValue + TryFromValue + WasmTy;
}
Expand description

Something that can be used by the runtime interface as type to communicate between wasm and the host.

Every type that should be used in a runtime interface function signature needs to implement this trait.

Required Associated Types§

Source

type FFIType: IntoValue + TryFromValue + WasmTy

The ffi type that is used to represent Self.

Implementations on Foreign Types§

Source§

impl RIType for bool

bool is passed as u32.

  • 1: true
  • 0: false
Source§

impl RIType for i8

The type is passed directly.

Source§

impl RIType for i16

The type is passed directly.

Source§

impl RIType for i32

The type is passed directly.

Source§

impl RIType for i64

The type is passed directly.

Source§

impl RIType for i128

u128/i128 is passed as u32.

The u32 is a pointer to an [u8; 16] array.

Source§

impl RIType for str

The type is passed as u64.

The u64 value is build by length 32bit << 32 | pointer 32bit

The length and the pointer are taken directly from Self.

Source§

impl RIType for u8

The type is passed directly.

Source§

impl RIType for u16

The type is passed directly.

Source§

impl RIType for u32

The type is passed directly.

Source§

impl RIType for u64

The type is passed directly.

Source§

impl RIType for u128

u128/i128 is passed as u32.

The u32 is a pointer to an [u8; 16] array.

Source§

impl<T> RIType for [T]

The type is passed as u64.

The u64 value is build by length 32bit << 32 | pointer 32bit

If T == u8 the length and the pointer are taken directly from Self. Otherwise Self is encoded and the length and the pointer are taken from the encoded vector.

Source§

impl<T> RIType for Vec<T>

The type is passed as u64.

The u64 value is build by length 32bit << 32 | pointer 32bit

If T == u8 the length and the pointer are taken directly from Self. Otherwise Self is encoded and the length and the pointer are taken from the encoded vector.

Source§

impl<const N: usize> RIType for [u8; N]

The type is passed as u32.

The u32 is the pointer to the array.

Implementors§

Source§

impl<T: Copy + Into<u8> + TryFrom<u8>> RIType for Enum<T>

The type is passed as u32.

The value is corresponds to the discriminant of the variant.

Source§

impl<T: Codec> RIType for Codec<T>

The type is passed as u64.

The u64 value is build by length 32bit << 32 | pointer 32bit

Self is encoded and the length and the pointer are taken from the encoded vector.

Source§

impl<T: PointerType> RIType for Pointer<T>

Source§

impl<T: PassBy> RIType for T

Source§

impl<T: PassByInner<Inner = I>, I: RIType> RIType for Inner<T, I>

The type is passed as the inner type.