pub trait MemoryStorage {
type Error: Debug;
Show 14 methods
// Required methods
fn get<I>(&self, index: I) -> Result<&I::Output, Self::Error>
where I: SliceIndex<[u8]>;
fn get_mut<I>(&mut self, index: I) -> Result<&mut I::Output, Self::Error>
where I: SliceIndex<[u8]>;
fn try_read_byte(&self, addr: usize) -> Result<u8, Self::Error>;
fn try_write_byte(
&mut self,
addr: usize,
byte: u8,
) -> Result<(), Self::Error>;
// Provided methods
fn read_byte(&self, addr: usize) -> u8 { ... }
fn write_byte(&mut self, addr: usize, byte: u8) { ... }
fn try_read<V: Value>(&self, addr: usize) -> Result<V, Self::Error> { ... }
fn read<V: Value>(&self, addr: usize) -> V { ... }
fn try_read_be<V: Value>(&self, addr: usize) -> Result<V, Self::Error> { ... }
fn read_be<V: Value>(&self, addr: usize) -> V { ... }
fn try_write<V: Value>(
&mut self,
addr: usize,
val: V,
) -> Result<(), Self::Error> { ... }
fn write<V: Value>(&mut self, addr: usize, val: V) { ... }
fn try_write_be<V: Value>(
&mut self,
addr: usize,
val: V,
) -> Result<(), Self::Error> { ... }
fn write_be<V: Value>(&mut self, addr: usize, val: V) { ... }
}
Expand description
The Memory
trait represents a chunk of memory that can read from,
or written to.
Required Associated Types§
Required Methods§
Sourcefn get<I>(&self, index: I) -> Result<&I::Output, Self::Error>where
I: SliceIndex<[u8]>,
fn get<I>(&self, index: I) -> Result<&I::Output, Self::Error>where
I: SliceIndex<[u8]>,
Returns a reference to an element or subslice depending on the type of index.
Sourcefn get_mut<I>(&mut self, index: I) -> Result<&mut I::Output, Self::Error>where
I: SliceIndex<[u8]>,
fn get_mut<I>(&mut self, index: I) -> Result<&mut I::Output, Self::Error>where
I: SliceIndex<[u8]>,
Returns a mutable reference to an element or subslice depending on the type of index.
Provided Methods§
Sourcefn read_byte(&self, addr: usize) -> u8
fn read_byte(&self, addr: usize) -> u8
Reads a byte at the given address.
Panics if the read failed
Sourcefn write_byte(&mut self, addr: usize, byte: u8)
fn write_byte(&mut self, addr: usize, byte: u8)
Writes a byte to the given address.
Panics if the write failed
Sourcefn try_read<V: Value>(&self, addr: usize) -> Result<V, Self::Error>
fn try_read<V: Value>(&self, addr: usize) -> Result<V, Self::Error>
Tries to read a generic Value
at the given address using little endian format.
Returns Err(x)
if the method failed to read a value at the address.
Sourcefn read<V: Value>(&self, addr: usize) -> V
fn read<V: Value>(&self, addr: usize) -> V
Reads a generic Value
at the given address using little endian format.
Panics if the method failed to read a value at the address.
Sourcefn try_read_be<V: Value>(&self, addr: usize) -> Result<V, Self::Error>
fn try_read_be<V: Value>(&self, addr: usize) -> Result<V, Self::Error>
Tries to read a generic Value
at the given address using big endian format.
Returns Err(x)
if the method failed to read a value at the address.
Sourcefn read_be<V: Value>(&self, addr: usize) -> V
fn read_be<V: Value>(&self, addr: usize) -> V
Reads a generic Value
at the given address using big endian format.
Panics if the method failed to read a value at the address.
Sourcefn try_write<V: Value>(
&mut self,
addr: usize,
val: V,
) -> Result<(), Self::Error>
fn try_write<V: Value>( &mut self, addr: usize, val: V, ) -> Result<(), Self::Error>
Tries to write a generic Value
to the given address using little endian format.
Returns Err(x)
if the method failed to write a value to the address.
Sourcefn write<V: Value>(&mut self, addr: usize, val: V)
fn write<V: Value>(&mut self, addr: usize, val: V)
Writes a generic Value
to the given address using little endian format.
Panics if the method failed to write a value to the address.
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.