wasmer_types

Trait MemorySize

source
pub unsafe trait MemorySize: Copy {
    type Offset: Default + Debug + Display + Eq + Ord + PartialEq<Self::Offset> + PartialOrd<Self::Offset> + Clone + Copy + Sync + Send + ValueType + Into<u64> + From<u32> + From<u16> + From<u8> + TryFrom<u64> + TryFrom<u32> + TryFrom<u16> + TryFrom<u8> + TryFrom<i32> + TryInto<usize> + TryInto<u64> + TryInto<u32> + TryInto<u16> + TryInto<u8> + TryInto<i32> + TryFrom<usize> + Add<Self::Offset> + Sum<Self::Offset> + AddAssign<Self::Offset> + SubAssign<Self::Offset> + 'static;
    type Native: NativeWasmType;

    const ZERO: Self::Offset;
    const ONE: Self::Offset;

    // Required methods
    fn offset_to_native(offset: Self::Offset) -> Self::Native;
    fn native_to_offset(native: Self::Native) -> Self::Offset;
    fn is_64bit() -> bool;
}
Expand description

Trait for the Memory32 and Memory64 marker types.

This allows code to be generic over 32-bit and 64-bit memories.

§Safety

Direct memory access is unsafe

Required Associated Constants§

source

const ZERO: Self::Offset

Zero value used for WasmPtr::is_null.

source

const ONE: Self::Offset

One value used for counting.

Required Associated Types§

source

type Offset: Default + Debug + Display + Eq + Ord + PartialEq<Self::Offset> + PartialOrd<Self::Offset> + Clone + Copy + Sync + Send + ValueType + Into<u64> + From<u32> + From<u16> + From<u8> + TryFrom<u64> + TryFrom<u32> + TryFrom<u16> + TryFrom<u8> + TryFrom<i32> + TryInto<usize> + TryInto<u64> + TryInto<u32> + TryInto<u16> + TryInto<u8> + TryInto<i32> + TryFrom<usize> + Add<Self::Offset> + Sum<Self::Offset> + AddAssign<Self::Offset> + SubAssign<Self::Offset> + 'static

Type used to represent an offset into a memory. This is u32 or u64.

source

type Native: NativeWasmType

Type used to pass this value as an argument or return value for a Wasm function.

Required Methods§

source

fn offset_to_native(offset: Self::Offset) -> Self::Native

Convert an Offset to a Native.

source

fn native_to_offset(native: Self::Native) -> Self::Offset

Convert a Native to an Offset.

source

fn is_64bit() -> bool

True if the memory is 64-bit

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.

Implementors§

source§

impl MemorySize for Memory32

source§

const ZERO: Self::Offset = {transmute(0x00000000): <memory::Memory32 as memory::MemorySize>::Offset}

source§

const ONE: Self::Offset = {transmute(0x00000001): <memory::Memory32 as memory::MemorySize>::Offset}

source§

type Offset = u32

source§

type Native = i32

source§

impl MemorySize for Memory64

source§

const ZERO: Self::Offset = {transmute(0x0000000000000000): <memory::Memory64 as memory::MemorySize>::Offset}

source§

const ONE: Self::Offset = {transmute(0x0000000000000001): <memory::Memory64 as memory::MemorySize>::Offset}

source§

type Offset = u64

source§

type Native = i64