pub trait Memory {
// Required methods
fn memory_mappings(&self) -> &[MemoryMap];
fn read_physical(
&self,
addr: PhysicalAddress,
buf: &mut [u8],
) -> MemoryAccessResult<()>;
// Provided methods
fn is_valid(&self, addr: PhysicalAddress, size: usize) -> bool { ... }
fn search(
&self,
addr: PhysicalAddress,
page_size: u64,
finder: &Finder<'_>,
buf: &mut [u8],
) -> MemoryAccessResult<Option<u64>> { ... }
}Expand description
A trait to specify how to read physical memory from a guest
This trait defines additional optional methods for specialization
Required Methods§
fn memory_mappings(&self) -> &[MemoryMap]
fn read_physical( &self, addr: PhysicalAddress, buf: &mut [u8], ) -> MemoryAccessResult<()>
Provided Methods§
fn is_valid(&self, addr: PhysicalAddress, size: usize) -> bool
Sourcefn search(
&self,
addr: PhysicalAddress,
page_size: u64,
finder: &Finder<'_>,
buf: &mut [u8],
) -> MemoryAccessResult<Option<u64>>
fn search( &self, addr: PhysicalAddress, page_size: u64, finder: &Finder<'_>, buf: &mut [u8], ) -> MemoryAccessResult<Option<u64>>
Search in a memory page with a finder.
A buffer is expected to avoid allocating a new one each time this function is called.
Returns the index of the needle within the page if found.