| 1 | //! Flash Partition utilities |
| 2 | |
| 3 | use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; |
| 4 | |
| 5 | mod asynch; |
| 6 | mod blocking; |
| 7 | |
| 8 | pub use asynch::Partition; |
| 9 | pub use blocking::BlockingPartition; |
| 10 | |
| 11 | /// Partition error |
| 12 | #[derive (Debug, PartialEq, Eq)] |
| 13 | #[cfg_attr (feature = "defmt" , derive(defmt::Format))] |
| 14 | pub enum Error<T> { |
| 15 | /// The requested flash area is outside the partition |
| 16 | OutOfBounds, |
| 17 | /// Underlying flash error |
| 18 | Flash(T), |
| 19 | } |
| 20 | |
| 21 | impl<T: NorFlashError> NorFlashError for Error<T> { |
| 22 | fn kind(&self) -> NorFlashErrorKind { |
| 23 | match self { |
| 24 | Error::OutOfBounds => NorFlashErrorKind::OutOfBounds, |
| 25 | Error::Flash(f: &T) => f.kind(), |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |