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§
Sourcefn read<T>(&self, address: u64) -> Result<T, VirtualMemoryError>where
T: BasicInt,
fn read<T>(&self, address: u64) -> Result<T, VirtualMemoryError>where
T: BasicInt,
Read a value from memory at the specified address
Sourceunsafe fn read_unchecked<T>(&self, address: u64) -> Twhere
T: BasicInt,
unsafe fn read_unchecked<T>(&self, address: u64) -> Twhere
T: BasicInt,
Unchecked read a value from memory at the specified address.
§Safety
The address and value must be in-bounds.
Sourcefn read_slice(
&self,
address: u64,
len: u32,
) -> Result<&[u8], VirtualMemoryError>
fn read_slice( &self, address: u64, len: u32, ) -> Result<&[u8], VirtualMemoryError>
Read a contiguous byte slice from memory
Sourcefn read_slice_up_to(&self, address: u64, len: u32) -> &[u8] ⓘ
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.
Sourcefn write<T>(&mut self, address: u64, value: T) -> Result<(), VirtualMemoryError>where
T: BasicInt,
fn write<T>(&mut self, address: u64, value: T) -> Result<(), VirtualMemoryError>where
T: BasicInt,
Write a value to memory at the specified address
Sourcefn write_slice(
&mut self,
address: u64,
data: &[u8],
) -> Result<(), VirtualMemoryError>
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.