From 0c2a559e65c265cd241e78ea2a4258052694170f Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Tue, 29 Oct 2024 20:49:49 +0000 Subject: [PATCH] Add optional defmt support. --- Cargo.toml | 7 +++++++ src/block.rs | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index c851083..31b4bd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,10 @@ documentation = "https://docs.rs/embedded-storage" readme = "README.md" keywords = ["storage"] categories = ["embedded", "hardware-support", "no-std"] + +[dependencies] +defmt = { version = "0.3.8", optional = true } + +[features] +default = [] +defmt = ["dep:defmt"] diff --git a/src/block.rs b/src/block.rs index ec81c5b..0b599fa 100644 --- a/src/block.rs +++ b/src/block.rs @@ -33,6 +33,7 @@ pub trait BlockDevice { /// The linear numeric address of a block (or sector). #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct BlockIdx(pub u64); impl BlockIdx { @@ -80,6 +81,7 @@ impl SubAssign for BlockIdx { /// /// This may be added to a [`BlockIdx`] to get another `BlockIdx`. #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct BlockCount(pub u64); impl Add for BlockCount {