diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2a78cd1..6ee57d56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: include: # Test MSRV - - rust: 1.56.0 # keep in sync with manifest rust-version + - rust: 1.62.0 # keep in sync with manifest rust-version TARGET: x86_64-unknown-linux-gnu # Test nightly but don't fail @@ -45,4 +45,4 @@ jobs: 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..f580ce7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ categories = ["no-std"] description = "serde-json for no_std programs" documentation = "https://docs.rs/serde-json-core" edition = "2018" -rust-version = "1.56.0" # keep in sync with ci, src/lib.rs, and README +rust-version = "1.62.0" # keep in sync with ci, src/lib.rs, and README keywords = ["serde", "json"] license = "MIT OR Apache-2.0" name = "serde-json-core" @@ -23,6 +23,11 @@ optional = true default-features = false version = "1.0.100" +[dependencies.defmt] +version = "0.3.5" +default-features = false +optional = true + [dev-dependencies] serde_derive = "1.0.100" diff --git a/README.md b/README.md index 07a00f80..e63ad91c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This project is developed and maintained by the [rust-embedded-community]. ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.56.0 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.62.0 and up. It *might* compile with older versions but that may change in any new patch release. ## License diff --git a/src/de/mod.rs b/src/de/mod.rs index dcfd9bd9..613323bc 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. @@ -74,7 +75,9 @@ pub enum Error { /// Error with a custom message that was preserved. #[cfg(feature = "custom-error-messages")] - CustomErrorWithMessage(heapless::String<64>), + CustomErrorWithMessage( + #[cfg_attr(feature = "defmt", defmt(Debug2Format))] heapless::String<64>, + ), } impl serde::de::StdError for Error {} diff --git a/src/lib.rs b/src/lib.rs index 3ac15832..7f2de3a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,7 +52,7 @@ //! //! # Minimum Supported Rust Version (MSRV) //! -//! This crate is guaranteed to compile on stable Rust 1.56.0 and up. It *might* compile with older +//! This crate is guaranteed to compile on stable Rust 1.62.0 and up. It *might* compile with older //! versions but that may change in any new patch release. #![deny(missing_docs)] 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