From fbad743ab086b056e52d47a7670d61b7faec15ab 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. --- .github/workflows/ci.yml | 2 +- Cargo.toml | 7 +++++++ README.md | 2 +- src/block.rs | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1499595..32338ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: include: # Test MSRV - - rust: 1.59.0 + - rust: 1.60.0 TARGET: x86_64-unknown-linux-gnu # Test nightly but don't fail 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/README.md b/README.md index baaae58..7212f44 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ These issues / PRs will be labeled as `proposal`s in the issue tracker. ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.59.0 and up. It _might_ +This crate is guaranteed to compile on stable Rust 1.60.0 and up. It _might_ compile with older versions but that may change in any new patch release. ## License 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 {