pub trait Storage {
// Required methods
fn read(
&mut self,
block: u32,
offset: u32,
buf: &mut [u8],
) -> Result<(), Error>;
fn write(
&mut self,
block: u32,
offset: u32,
data: &[u8],
) -> Result<(), Error>;
fn erase(&mut self, block: u32) -> Result<(), Error>;
// Provided method
fn sync(&mut self) -> Result<(), Error> { ... }
}Expand description
Block device storage backend.
Implement this trait to connect a flash chip, SD card, or any other block
device. See RamStorage for a minimal example.
Required Methods§
Sourcefn read(&mut self, block: u32, offset: u32, buf: &mut [u8]) -> Result<(), Error>
fn read(&mut self, block: u32, offset: u32, buf: &mut [u8]) -> Result<(), Error>
Read buf.len() bytes starting at offset within block.