wasmer

Trait MemorySize

Source
pub unsafe trait MemorySize: Copy {
    type Offset: Default + Debug + Display + Eq + Ord + PartialEq + PartialOrd + 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 + Sum + AddAssign + SubAssign + '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 + PartialOrd + 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 + Sum + AddAssign + SubAssign + '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: <Memory32 as MemorySize>::Offset = {transmute(0x00000000): <wasmer_types::Memory32 as wasmer_types::MemorySize>::Offset}

Source§

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

Source§

type Offset = u32

Source§

type Native = i32

Source§

impl MemorySize for Memory64

Source§

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

Source§

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

Source§

type Offset = u64

Source§

type Native = i64