2023-05-27 10:29:21 +02:00
|
|
|
//! Flash Partition utilities
|
|
|
|
|
|
|
|
use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
|
|
|
|
|
|
|
|
#[cfg(feature = "nightly")]
|
|
|
|
mod asynch;
|
|
|
|
mod blocking;
|
|
|
|
|
|
|
|
#[cfg(feature = "nightly")]
|
|
|
|
pub use asynch::Partition;
|
|
|
|
pub use blocking::BlockingPartition;
|
|
|
|
|
|
|
|
/// Partition error
|
2023-10-06 17:45:35 +02:00
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
2023-05-27 10:29:21 +02:00
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
|
|
|
pub enum Error<T> {
|
|
|
|
/// The requested flash area is outside the partition
|
|
|
|
OutOfBounds,
|
|
|
|
/// Underlying flash error
|
|
|
|
Flash(T),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: NorFlashError> NorFlashError for Error<T> {
|
|
|
|
fn kind(&self) -> NorFlashErrorKind {
|
|
|
|
match self {
|
|
|
|
Error::OutOfBounds => NorFlashErrorKind::OutOfBounds,
|
|
|
|
Error::Flash(f) => f.kind(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|