Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ documentation = "https://docs.rs/embedded-storage"
readme = "README.md"
keywords = ["storage"]
categories = ["embedded", "hardware-support", "no-std"]

[features]
defmt = ["dep:defmt"]

[dependencies]
defmt = { version = "1.0.1", optional = true }
4 changes: 4 additions & 0 deletions embedded-storage-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ readme = "README.md"
keywords = ["storage"]
categories = ["embedded", "hardware-support", "no-std"]

[features]
defmt = ["dep:defmt", "embedded-storage/defmt"]

[dependencies]
embedded-storage = { version = "0.3.1", path = "../" }
defmt = { version = "1.0.1", optional = true }
4 changes: 2 additions & 2 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ where
I: Iterator<Item = R>,
{
/// Obtain an [`OverlapIterator`] over a subslice of `memory` that overlaps with the region in `self`
fn overlaps(self, memory: &'a [u8], base_address: u32) -> OverlapIterator<R, I>;
fn overlaps(self, memory: &'a [u8], base_address: u32) -> OverlapIterator<'a, R, I>;
}

impl<'a, R, I> Iterator for OverlapIterator<'a, R, I>
Expand Down Expand Up @@ -54,7 +54,7 @@ where
R: Region,
I: Iterator<Item = R>,
{
fn overlaps(self, memory: &'a [u8], base_address: u32) -> OverlapIterator<R, I> {
fn overlaps(self, memory: &'a [u8], base_address: u32) -> OverlapIterator<'a, R, I> {
OverlapIterator {
memory,
regions: self,
Expand Down
12 changes: 12 additions & 0 deletions src/nor_flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ use crate::{iter::IterableByOverlaps, ReadStorage, Region, Storage};
///
/// NOR flash implementations must use an error type implementing this trait. This permits generic
/// code to extract a generic error kind.
#[cfg(not(feature = "defmt"))]
pub trait NorFlashError: core::fmt::Debug {
/// Convert a specific NOR flash error into a generic error kind.
fn kind(&self) -> NorFlashErrorKind;
}

/// NOR flash errors.
///
/// NOR flash implementations must use an error type implementing this trait. This permits generic
/// code to extract a generic error kind.
#[cfg(feature = "defmt")]
pub trait NorFlashError: core::fmt::Debug + defmt::Format {
/// Convert a specific NOR flash error into a generic error kind.
fn kind(&self) -> NorFlashErrorKind;
}

impl NorFlashError for core::convert::Infallible {
fn kind(&self) -> NorFlashErrorKind {
match *self {}
Expand All @@ -26,6 +37,7 @@ pub trait ErrorType {
/// NOR flash implementations must map their error to those generic error kinds through the
/// [`NorFlashError`] trait.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum NorFlashErrorKind {
/// The arguments are not properly aligned.
Expand Down