pub use embedded_storage::nor_flash::{ErrorType, NorFlashError, NorFlashErrorKind};
pub trait ReadNorFlash: ErrorType {
const READ_SIZE: usize;
async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error>;
fn capacity(&self) -> usize;
}
pub trait NorFlash: ReadNorFlash {
const WRITE_SIZE: usize;
const ERASE_SIZE: usize;
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error>;
async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error>;
}
impl<T: ReadNorFlash> ReadNorFlash for &mut T {
const READ_SIZE: usize = T::READ_SIZE;
async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
T::read(self, offset, bytes).await
}
fn capacity(&self) -> usize {
T::capacity(self)
}
}
impl<T: NorFlash> NorFlash for &mut T {
const WRITE_SIZE: usize = T::WRITE_SIZE;
const ERASE_SIZE: usize = T::ERASE_SIZE;
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
T::erase(self, from, to).await
}
async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
T::write(self, offset, bytes).await
}
}
pub trait MultiwriteNorFlash: NorFlash {}