pub struct MemoryMap<'buf> { /* private fields */ }
Expand description
An accessory to the memory map that can be either iterated or indexed like an array.
A MemoryMap
is always associated with the
unique MemoryMapKey
contained in the struct.
To iterate over the entries, call MemoryMap::entries
. To get a sorted
map, you manually have to call MemoryMap::sort
first.
Implementations§
source§impl<'buf> MemoryMap<'buf>
impl<'buf> MemoryMap<'buf>
sourcepub fn from_raw(buf: &'buf mut [u8], entry_size: usize) -> Self
pub fn from_raw(buf: &'buf mut [u8], entry_size: usize) -> Self
Creates a MemoryMap
from the given buffer and entry size.
This allows parsing a memory map provided by a kernel after boot services have already exited.
sourcepub fn key(&self) -> MemoryMapKey
pub fn key(&self) -> MemoryMapKey
Returns the unique MemoryMapKey
associated with the memory map.
sourcepub fn sort(&mut self)
pub fn sort(&mut self)
Sorts the memory map by physical address in place. This operation is optional and should be invoked only once.
sourcepub fn entries(&self) -> MemoryMapIter<'_> ⓘ
pub fn entries(&self) -> MemoryMapIter<'_> ⓘ
Returns an iterator over the contained memory map. To get a sorted map,
call MemoryMap::sort
first.
sourcepub fn get(&self, index: usize) -> Option<&'buf MemoryDescriptor>
pub fn get(&self, index: usize) -> Option<&'buf MemoryDescriptor>
Returns a reference to the MemoryDescriptor
at index
or None
if out of bounds.
sourcepub fn get_mut(&mut self, index: usize) -> Option<&'buf mut MemoryDescriptor>
pub fn get_mut(&mut self, index: usize) -> Option<&'buf mut MemoryDescriptor>
Returns a mut reference to the MemoryDescriptor
at index
or None
if out of bounds.