pub unsafe trait FromToNativeWasmTypewhere
    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.

Implementations on Foreign Types§

source§

impl FromToNativeWasmType for u64

§

type Native = i64

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for f64

§

type Native = f64

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for i8

§

type Native = i32

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for u8

§

type Native = i32

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for u32

§

type Native = i32

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for Option<ExternRef>

§

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 i64

§

type Native = i64

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for i16

§

type Native = i32

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for i32

§

type Native = i32

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for f32

§

type Native = f32

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for u16

§

type Native = i32

source§

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

source§

fn to_native(self) -> Self::Native

source§

impl FromToNativeWasmType for Option<Function>

§

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

Implementors§