diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2a78cd1..70629eae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,9 +40,9 @@ jobs: - uses: actions-rs/cargo@v1 with: command: build - args: --target=${{ matrix.TARGET }} + args: --target=${{ matrix.TARGET }} --all-features - uses: actions-rs/cargo@v1 if: ${{ contains(matrix.TARGET, 'x86_64') }} with: command: test - args: --target=${{ matrix.TARGET }} + args: --target=${{ matrix.TARGET }} --all-features diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3fca4b..6bd1ee2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added + +- Support for optional package `defmt` which allows for easy conversion for +error types when using tools like `probe-rs` for logging over debuggers. + ## [v0.5.1] - 2023-07-26 ### Added diff --git a/Cargo.toml b/Cargo.toml index 71fd9b5a..d8d1d23f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,11 @@ optional = true default-features = false version = "1.0.100" +[dependencies.defmt] +version = "0.3.0" +default-features = false +optional = true + [dev-dependencies] serde_derive = "1.0.100" diff --git a/src/de/mod.rs b/src/de/mod.rs index dcfd9bd9..c04d7379 100644 --- a/src/de/mod.rs +++ b/src/de/mod.rs @@ -19,6 +19,7 @@ pub type Result = core::result::Result; /// This type represents all possible errors that can occur when deserializing JSON data #[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr(not(feature = "custom-error-messages"), derive(Copy))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum Error { /// EOF while parsing a list. diff --git a/src/ser/mod.rs b/src/ser/mod.rs index 75153e8d..ede8b624 100644 --- a/src/ser/mod.rs +++ b/src/ser/mod.rs @@ -22,6 +22,7 @@ pub type Result = ::core::result::Result; /// This type represents all possible errors that can occur when serializing JSON data #[derive(Debug, PartialEq, Eq, Copy, Clone)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum Error { /// Buffer is full