pub trait FlashAccess {
type Error;
// Required method
fn exchange(&mut self, data: &[u8]) -> Result<Vec<u8>, Self::Error>;
// Provided methods
fn write(&mut self, data: &[u8]) -> Result<(), Self::Error> { ... }
fn delay(&mut self, duration: Duration) { ... }
}Expand description
Trait for objects which provide access to SPI flash.
Providers only need to implement exchange(), which asserts CS, writes all the bytes
in data, then returns all the received bytes. If it provides a performance optimisation,
providers may also implement write(), which does not require the received data.
From<FlashAccess::Error> must be implemented for spi_flash::Error; for example in your
implementation code, add:
impl From<MyError> for spi_flash::Error {
fn from(err: MyError) -> spi_flash::Error {
spi_flash::Error::Access(err.into())
}
}