Skip to main content

LinearMemory

Struct LinearMemory 

Source
pub struct LinearMemory<'a> { /* private fields */ }
Expand description

A flat byte buffer addressed by offset: the transport for Wasm linear memory, and for any caller whose pointers are offsets into one buffer. Offset 0 is null.

Implementations§

Source§

impl<'a> LinearMemory<'a>

Source

pub fn new(bytes: &'a mut [u8], word_bits: u32) -> Self

Trait Implementations§

Source§

impl Transport for LinearMemory<'_>

Source§

fn word_bits(&self) -> u32

Width in bits of the caller’s pointer-sized word, 32 or 64, never wider than the host’s usize. It tells a zero-extended 32-bit word from a sign-extended 64-bit one.
Source§

fn bytes(&self, address: Word, length: usize) -> Result<&[u8]>

Borrow length bytes at address. A null address is valid only for an empty range.
Source§

fn bytes_mut(&mut self, address: Word, length: usize) -> Result<&mut [u8]>

Exclusively borrow length bytes at address.
Source§

fn c_string(&self, address: Word, limit: usize) -> Result<&CStr>

Borrow the NUL-terminated string at address without copying it. A string longer than limit bytes, NUL included, is ResourceLimit; a null address or a string that leaves memory is InvalidMemory.

Auto Trait Implementations§

§

impl<'a> Freeze for LinearMemory<'a>

§

impl<'a> RefUnwindSafe for LinearMemory<'a>

§

impl<'a> Send for LinearMemory<'a>

§

impl<'a> Sync for LinearMemory<'a>

§

impl<'a> Unpin for LinearMemory<'a>

§

impl<'a> UnsafeUnpin for LinearMemory<'a>

§

impl<'a> !UnwindSafe for LinearMemory<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.