pub trait Reader {
type Error: Debug;
// Required methods
fn read(
&mut self,
addr: u32,
buf: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn update_base_address(&mut self, new_base: u32);
}Expand description
Reader trait.
Required Associated Types§
Required Methods§
Sourcefn read(
&mut self,
addr: u32,
buf: &mut [u8],
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn read( &mut self, addr: u32, buf: &mut [u8], ) -> impl Future<Output = Result<(), Self::Error>> + Send
Read bytes from the firmware at the specified absolute address.
§Arguments
addr- The absolute address to read from (e.g.,0x08000200)buf- Buffer to fill with the read data
§Errors
Returns an error if:
- The address is out of bounds for the firmware
- The underlying read operation fails (I/O error, communication error, etc.)
- The requested read size would exceed firmware boundaries
§Performance Notes
Implementations should optimize for small reads (1-256 bytes) as the parser typically reads headers and metadata in small chunks. For embedded implementations reading via debug interfaces, consider implementing bulk reads and internal buffering to reduce round-trip overhead.
Sourcefn update_base_address(&mut self, new_base: u32)
fn update_base_address(&mut self, new_base: u32)
Updates the reader’s base address if it is later detected that it needs to change.
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.