pub trait MemoryMapper {
// Required methods
fn create(address: usize, size: usize) -> Result<Self, &'static str>
where Self: Sized;
fn len(&self) -> usize;
fn as_ptr<T>(&self) -> *const T;
fn as_mut_ptr<T>(&mut self) -> *mut T;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn as_range(&self, range: impl RangeBounds<usize>) -> &[u8] ⓘ { ... }
fn as_mut_range(&mut self, range: impl RangeBounds<usize>) -> &mut [u8] ⓘ { ... }
}Expand description
Maps a memory region to a pointer.
Required Methods§
Sourcefn create(address: usize, size: usize) -> Result<Self, &'static str>where
Self: Sized,
fn create(address: usize, size: usize) -> Result<Self, &'static str>where
Self: Sized,
Create a Mapper that maps the given physical address and size.
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the maximum length that can be addressed. The end of this
memory mapped range is address + len().
Sourcefn as_mut_ptr<T>(&mut self) -> *mut T
fn as_mut_ptr<T>(&mut self) -> *mut T
Returns a mutable pointer to the mapped memory region.
Provided Methods§
Sourcefn as_range(&self, range: impl RangeBounds<usize>) -> &[u8] ⓘ
fn as_range(&self, range: impl RangeBounds<usize>) -> &[u8] ⓘ
Creates an inner range of bytes. The offsets are relative to the base
of the mapped memory, e.g. as_range(0..4) will return the first 4
bytes of the mapped memory (a memory mapping to address 0x12340000 will
map 0x12340000..0x12340004).
Sourcefn as_mut_range(&mut self, range: impl RangeBounds<usize>) -> &mut [u8] ⓘ
fn as_mut_range(&mut self, range: impl RangeBounds<usize>) -> &mut [u8] ⓘ
Creates an inner mutable range of bytes.
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.