Skip to main content

VirtualMemory

Trait VirtualMemory 

Source
pub trait VirtualMemory {
    // Required methods
    fn read<T>(&self, address: u64) -> Result<T, VirtualMemoryError>
       where T: BasicInt;
    unsafe fn read_unchecked<T>(&self, address: u64) -> T
       where T: BasicInt;
    fn read_slice(
        &self,
        address: u64,
        len: u32,
    ) -> Result<&[u8], VirtualMemoryError>;
    fn read_slice_up_to(&self, address: u64, len: u32) -> &[u8] ;
    fn write<T>(
        &mut self,
        address: u64,
        value: T,
    ) -> Result<(), VirtualMemoryError>
       where T: BasicInt;
    fn write_slice(
        &mut self,
        address: u64,
        data: &[u8],
    ) -> Result<(), VirtualMemoryError>;
}
Expand description

Virtual memory interface

Required Methods§

Source

fn read<T>(&self, address: u64) -> Result<T, VirtualMemoryError>
where T: BasicInt,

Read a value from memory at the specified address

Source

unsafe fn read_unchecked<T>(&self, address: u64) -> T
where T: BasicInt,

Unchecked read a value from memory at the specified address.

§Safety

The address and value must be in-bounds.

Source

fn read_slice( &self, address: u64, len: u32, ) -> Result<&[u8], VirtualMemoryError>

Read a contiguous byte slice from memory

Source

fn read_slice_up_to(&self, address: u64, len: u32) -> &[u8]

Read as many contiguous bytes as possible starting at address, up to len bytes total.

Can return an empty slice in cases like when the address is out of bounds.

Source

fn write<T>(&mut self, address: u64, value: T) -> Result<(), VirtualMemoryError>
where T: BasicInt,

Write a value to memory at the specified address

Source

fn write_slice( &mut self, address: u64, data: &[u8], ) -> Result<(), VirtualMemoryError>

Write a contiguous byte slice to memory

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§