pub trait MemDevice {
const LEN: usize;
// Required methods
fn read_bytes_relative(&self, addr: RelativeAddr, data: &mut [u8]);
fn write_bytes_relative(&mut self, addr: RelativeAddr, data: &[u8]);
// Provided methods
fn read_relative_into<V>(&self, addr: RelativeAddr, dest: &mut V)
where V: MemValue { ... }
fn read_relative<V>(&self, addr: RelativeAddr) -> V
where V: MemValue + Default { ... }
fn write_relative_from<V>(&mut self, addr: RelativeAddr, source: &V)
where V: MemValue { ... }
fn write_relative<V>(&mut self, addr: RelativeAddr, val: V)
where V: MemValue { ... }
fn read_byte_relative(&self, addr: RelativeAddr) -> u8 { ... }
fn write_byte_relative(&mut self, addr: RelativeAddr, data: u8) { ... }
}Expand description
Provides access to system memory.
Required Associated Constants§
Required Methods§
Sourcefn read_bytes_relative(&self, addr: RelativeAddr, data: &mut [u8])
fn read_bytes_relative(&self, addr: RelativeAddr, data: &mut [u8])
Read a range of bytes into a slice. The read bytes must not wrap past the end of the device.
Sourcefn write_bytes_relative(&mut self, addr: RelativeAddr, data: &[u8])
fn write_bytes_relative(&mut self, addr: RelativeAddr, data: &[u8])
Write a range of bytes into memory from a slice. The slice must not exceed the length of the MemDevice.
Provided Methods§
Sourcefn read_relative_into<V>(&self, addr: RelativeAddr, dest: &mut V)where
V: MemValue,
fn read_relative_into<V>(&self, addr: RelativeAddr, dest: &mut V)where
V: MemValue,
Read a typed value from this MemDevice. The value must be fully contained within this device.
Sourcefn read_relative<V>(&self, addr: RelativeAddr) -> V
fn read_relative<V>(&self, addr: RelativeAddr) -> V
Read a typed value from this MemDevice. The value must be fully contained within this device.
Sourcefn write_relative_from<V>(&mut self, addr: RelativeAddr, source: &V)where
V: MemValue,
fn write_relative_from<V>(&mut self, addr: RelativeAddr, source: &V)where
V: MemValue,
Write a typed value into this MemDevice. The value must fit fully within the device.
Sourcefn write_relative<V>(&mut self, addr: RelativeAddr, val: V)where
V: MemValue,
fn write_relative<V>(&mut self, addr: RelativeAddr, val: V)where
V: MemValue,
Write a typed value into this MemDevice. The value must fit fully within the device.
Sourcefn read_byte_relative(&self, addr: RelativeAddr) -> u8
fn read_byte_relative(&self, addr: RelativeAddr) -> u8
Read the byte at the specified address.
The default implementation just calls read_range_relative with a single-byte
slice. A mem device may override this method if it can provide a more efficient
single-byte read.
Sourcefn write_byte_relative(&mut self, addr: RelativeAddr, data: u8)
fn write_byte_relative(&mut self, addr: RelativeAddr, data: u8)
Write the byte at the sepcified address.
The default implementation just calls write_range_relative with a single-byte
slice. A mem device may override this method if it can provide a more efficient
single-byte write.
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.
Implementations on Foreign Types§
Source§impl MemDevice for u8
A u8 acts as a single-byte memory device.
impl MemDevice for u8
A u8 acts as a single-byte memory device.