Skip to content

Commit

Permalink
Add optional defmt support.
Browse files Browse the repository at this point in the history
  • Loading branch information
qwandor committed Oct 29, 2024
1 parent 8a340f4 commit 0c2a559
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 2 additions & 0 deletions src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub trait BlockDevice<const BLOCK_SIZE: usize = 512> {

/// 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 {
Expand Down Expand Up @@ -80,6 +81,7 @@ impl SubAssign<BlockCount> 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<BlockCount> for BlockCount {
Expand Down

0 comments on commit 0c2a559

Please sign in to comment.