Skip to main content

LazyLinearMemory

Struct LazyLinearMemory 

Source
pub struct LazyLinearMemory { /* private fields */ }
Expand description

A linear memory wrapper that materializes its inner backend on first access.

If the wrapped backend fails to create the inner memory during first access, this wrapper will panic.

Implementations§

Source§

impl LazyLinearMemory

Source

pub fn try_new(ty: MemoryType, backend: MemoryBackend) -> Result<Self>

Creates a lazy memory for ty using backend for the eventual materialized storage.

Trait Implementations§

Source§

impl Debug for LazyLinearMemory

Available on crate feature debug only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl LinearMemory for LazyLinearMemory

Source§

fn len(&self) -> usize

Returns the current memory length in bytes.
Source§

fn grow_to(&mut self, new_len: usize) -> Result<(), Trap>

Grows the memory to new_len bytes. Read more
Source§

fn read(&self, addr: usize, dst: &mut [u8]) -> usize

Reads up to dst.len() bytes starting at addr and returns the number of bytes read. Read more
Source§

fn write(&mut self, addr: usize, src: &[u8]) -> usize

Writes up to src.len() bytes starting at addr and returns the number of bytes written. Read more
Source§

fn write_all(&mut self, addr: usize, src: &[u8]) -> Option<()>

Writes all bytes in src starting at addr, or returns None if any byte could not be written.
Source§

fn fill(&mut self, addr: usize, len: usize, val: u8) -> Option<()>

Fills the range [addr, addr + len) with val.
Source§

fn copy_within(&mut self, dst: usize, src: usize, len: usize) -> Option<()>

Copies len bytes from src to dst within the same memory.
Source§

fn read_exact(&self, addr: usize, dst: &mut [u8]) -> Option<()>

Reads exactly dst.len() bytes starting at addr.
Source§

fn read_vec(&self, addr: usize, len: usize) -> Option<Vec<u8>>

Reads len bytes starting at addr into a newly allocated buffer.
Source§

fn read_8(&self, base: u64, offset: u64) -> Result<u8, Trap>

Reads exactly 1 byte at the effective address base + offset.
Source§

fn read_16(&self, base: u64, offset: u64) -> Result<[u8; 2], Trap>

Reads exactly 2 bytes at the effective address base + offset.
Source§

fn read_32(&self, base: u64, offset: u64) -> Result<[u8; 4], Trap>

Reads exactly 4 bytes at the effective address base + offset.
Source§

fn read_64(&self, base: u64, offset: u64) -> Result<[u8; 8], Trap>

Reads exactly 8 bytes at the effective address base + offset.
Source§

fn read_128(&self, base: u64, offset: u64) -> Result<[u8; 16], Trap>

Reads exactly 16 bytes at the effective address base + offset.
Source§

fn write_8(&mut self, base: u64, offset: u64, byte: u8) -> Result<(), Trap>

Writes exactly 1 byte at the effective address base + offset.
Source§

fn write_16( &mut self, base: u64, offset: u64, bytes: [u8; 2], ) -> Result<(), Trap>

Writes exactly 2 bytes at the effective address base + offset.
Source§

fn write_32( &mut self, base: u64, offset: u64, bytes: [u8; 4], ) -> Result<(), Trap>

Writes exactly 4 bytes at the effective address base + offset.
Source§

fn write_64( &mut self, base: u64, offset: u64, bytes: [u8; 8], ) -> Result<(), Trap>

Writes exactly 8 bytes at the effective address base + offset.
Source§

fn write_128( &mut self, base: u64, offset: u64, bytes: [u8; 16], ) -> Result<(), Trap>

Writes exactly 16 bytes at the effective address base + offset.
Source§

fn is_empty(&self) -> bool

Returns true if the memory is empty.

Auto Trait Implementations§

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.