wasmer::utils::native::convert

Trait NativeWasmType

pub trait NativeWasmType: Sized {
    type Abi: Copy + Debug;

    const WASM_TYPE: Type;
}
Expand description

NativeWasmType represents a Wasm type that has a direct representation on the host (hence the “native” term).

It uses the Rust Type system to automatically detect the Wasm type associated with a native Rust type.

use wasmer_types::{NativeWasmType, Type};

let wasm_type = i32::WASM_TYPE;
assert_eq!(wasm_type, Type::I32);

Note: This strategy will be needed later to automatically detect the signature of a Rust function.

Required Associated Constants§

const WASM_TYPE: Type

Type for this NativeWasmType.

Required Associated Types§

type Abi: Copy + Debug

The ABI for this type (i32, i64, f32, f64)

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.

Implementations on Foreign Types§

§

impl NativeWasmType for f32

§

const WASM_TYPE: Type = Type::F32

§

type Abi = f32

§

impl NativeWasmType for f64

§

const WASM_TYPE: Type = Type::F64

§

type Abi = f64

§

impl NativeWasmType for i32

§

const WASM_TYPE: Type = Type::I32

§

type Abi = i32

§

impl NativeWasmType for i64

§

const WASM_TYPE: Type = Type::I64

§

type Abi = i64

§

impl NativeWasmType for u32

§

const WASM_TYPE: Type = Type::I32

§

type Abi = u32

§

impl NativeWasmType for u64

§

const WASM_TYPE: Type = Type::I64

§

type Abi = u64

§

impl NativeWasmType for u128

§

const WASM_TYPE: Type = Type::V128

§

type Abi = u128

§

impl<T> NativeWasmType for Option<T>
where T: NativeWasmType,

§

const WASM_TYPE: Type = T::WASM_TYPE

§

type Abi = <T as NativeWasmType>::Abi

Implementors§

Source§

impl NativeWasmType for ExternRef

Source§

const WASM_TYPE: Type = Type::ExternRef

Source§

type Abi = usize

Source§

impl NativeWasmType for Function

Source§

const WASM_TYPE: Type = Type::FuncRef

Source§

type Abi = usize

§

impl NativeWasmType for Memory32

§

const WASM_TYPE: Type = <<Self as MemorySize>::Native as NativeWasmType>::WASM_TYPE

§

type Abi = <<Memory32 as MemorySize>::Native as NativeWasmType>::Abi

§

impl NativeWasmType for Memory64

§

const WASM_TYPE: Type = <<Self as MemorySize>::Native as NativeWasmType>::WASM_TYPE

§

type Abi = <<Memory64 as MemorySize>::Native as NativeWasmType>::Abi