Trait wasmer::FromToNativeWasmType

source ·
pub unsafe trait FromToNativeWasmType
where Self: Sized,
{ type Native: NativeWasmTypeInto; // Required methods fn from_native(native: Self::Native) -> Self; fn to_native(self) -> Self::Native; // Provided method fn is_from_store(&self, _store: &impl AsStoreRef) -> bool { ... } }
Expand description

A trait to convert a Rust value to a WasmNativeType value, or to convert WasmNativeType value to a Rust value.

This trait should ideally be split into two traits: FromNativeWasmType and ToNativeWasmType but it creates a non-negligible complexity in the WasmTypeList implementation.

§Safety

This trait is unsafe given the nature of how values are written and read from the native stack

Required Associated Types§

source

type Native: NativeWasmTypeInto

Native Wasm type.

Required Methods§

source

fn from_native(native: Self::Native) -> Self

Convert a value of kind Self::Native to Self.

§Panics

This method panics if native cannot fit in the Self type`.

source

fn to_native(self) -> Self::Native

Convert self to Self::Native.

§Panics

This method panics if self cannot fit in the Self::Native type.

Provided Methods§

source

fn is_from_store(&self, _store: &impl AsStoreRef) -> bool

Returns whether the given value is from the given store.

This always returns true for primitive types that can be used with any context.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FromToNativeWasmType for Option<ExternRef>

source§

type Native = Option<ExternRef>

source§

fn to_native(self) -> Self::Native

source§

fn from_native(n: Self::Native) -> Self

source§

fn is_from_store(&self, store: &impl AsStoreRef) -> bool

source§

impl FromToNativeWasmType for Option<Function>

source§

type Native = Option<Function>

source§

fn to_native(self) -> Self::Native

source§

fn from_native(n: Self::Native) -> Self

source§

fn is_from_store(&self, store: &impl AsStoreRef) -> bool

source§

impl FromToNativeWasmType for f32

source§

type Native = f32

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for f64

source§

type Native = f64

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for i8

source§

type Native = i32

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for i16

source§

type Native = i32

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for i32

source§

type Native = i32

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for i64

source§

type Native = i64

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for u8

source§

type Native = i32

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for u16

source§

type Native = i32

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for u32

source§

type Native = i32

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for u64

source§

type Native = i64

source§

fn from_native(native: Self::Native) -> Self

source§

fn to_native(self) -> Self::Native

Implementors§