From 03570d524ce3eb96d834972eb265b672347b8efd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Mar 2026 11:11:59 +0100 Subject: [PATCH 1/2] add defmt support --- Cargo.toml | 3 +++ src/nor_flash.rs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c851083..f1aab22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,6 @@ documentation = "https://docs.rs/embedded-storage" readme = "README.md" keywords = ["storage"] categories = ["embedded", "hardware-support", "no-std"] + +[dependencies] +defmt = { version = "1", optional = true } diff --git a/src/nor_flash.rs b/src/nor_flash.rs index c241545..3c9b9b3 100644 --- a/src/nor_flash.rs +++ b/src/nor_flash.rs @@ -4,7 +4,7 @@ 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. -pub trait NorFlashError: core::fmt::Debug { +pub trait NorFlashError { /// Convert a specific NOR flash error into a generic error kind. fn kind(&self) -> NorFlashErrorKind; } @@ -26,6 +26,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. From 618bee3d5c5eed750a429ac87d19893af27ee085 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 Mar 2026 13:35:11 +0100 Subject: [PATCH 2/2] add back trait bound --- src/nor_flash.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nor_flash.rs b/src/nor_flash.rs index 3c9b9b3..186f9a9 100644 --- a/src/nor_flash.rs +++ b/src/nor_flash.rs @@ -4,7 +4,7 @@ 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. -pub trait NorFlashError { +pub trait NorFlashError: core::fmt::Debug { /// Convert a specific NOR flash error into a generic error kind. fn kind(&self) -> NorFlashErrorKind; }