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§
Required Associated Types§
Sourcetype 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 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
.
Sourcetype Native: NativeWasmType
type Native: NativeWasmType
Type used to pass this value as an argument or return value for a Wasm function.
Required Methods§
Sourcefn offset_to_native(offset: Self::Offset) -> Self::Native
fn offset_to_native(offset: Self::Offset) -> Self::Native
Convert an Offset
to a Native
.
Sourcefn native_to_offset(native: Self::Native) -> Self::Offset
fn native_to_offset(native: Self::Native) -> Self::Offset
Convert a Native
to an Offset
.
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.