Skip to content

Commit 0c2a559

Browse files
committed
Add optional defmt support.
1 parent 8a340f4 commit 0c2a559

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ documentation = "https://docs.rs/embedded-storage"
1313
readme = "README.md"
1414
keywords = ["storage"]
1515
categories = ["embedded", "hardware-support", "no-std"]
16+
17+
[dependencies]
18+
defmt = { version = "0.3.8", optional = true }
19+
20+
[features]
21+
default = []
22+
defmt = ["dep:defmt"]

src/block.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub trait BlockDevice<const BLOCK_SIZE: usize = 512> {
3333

3434
/// The linear numeric address of a block (or sector).
3535
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
36+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
3637
pub struct BlockIdx(pub u64);
3738

3839
impl BlockIdx {
@@ -80,6 +81,7 @@ impl SubAssign<BlockCount> for BlockIdx {
8081
///
8182
/// This may be added to a [`BlockIdx`] to get another `BlockIdx`.
8283
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
84+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8385
pub struct BlockCount(pub u64);
8486

8587
impl Add<BlockCount> for BlockCount {

0 commit comments

Comments
 (0)