Skip to content

io: Update defmt to 1.0, rename feature from "defmt_03" to "defmt" #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cargo build
--workspace
--target thumbv7m-none-eabi
--features async,defmt-03
--features async,defmt-03,embedded-io/defmt,embedded-io-async/defmt

msrv-1-81:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions embedded-io-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ categories = [
[features]
std = ["alloc", "embedded-io/std"]
alloc = ["embedded-io/alloc"]
defmt-03 = ["dep:defmt-03", "embedded-io/defmt-03"]
defmt = ["dep:defmt", "embedded-io/defmt"]

[dependencies]
embedded-io = { version = "0.6.1", path = "../embedded-io" }
defmt-03 = { package = "defmt", version = "0.3", optional = true }
defmt = { package = "defmt", version = "1", optional = true }

[package.metadata.docs.rs]
features = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion embedded-io-async/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This project is developed and maintained by the [HAL team](https://github.com/ru

- **`std`**: Adds `From` impls to convert to/from `std::io` structs.
- **`alloc`**: Adds blanket impls for `Box`, adds `Write` impl to `Vec`.
- **`defmt-03`**: Derive `defmt::Format` from `defmt` 0.3 for enums and structs.
- **`defmt`**: Derive `defmt::Format` from `defmt` 1.0 for enums and structs.

## Minimum Supported Rust Version (MSRV)

Expand Down
4 changes: 2 additions & 2 deletions embedded-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ categories = [
[features]
std = ["alloc"]
alloc = []
defmt-03 = ["dep:defmt-03"]
defmt = ["dep:defmt"]

[dependencies]
defmt-03 = { package = "defmt", version = "0.3", optional = true }
defmt = { version = "1", optional = true }

[package.metadata.docs.rs]
features = ["std"]
Expand Down
14 changes: 5 additions & 9 deletions embedded-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

use core::fmt;

// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`.
#[cfg(feature = "defmt-03")]
use defmt_03 as defmt;

#[cfg(feature = "alloc")]
extern crate alloc;

Expand All @@ -18,7 +14,7 @@ mod impls;
///
/// This is the `embedded-io` equivalent of [`std::io::SeekFrom`].
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SeekFrom {
/// Sets the offset to the provided number of bytes.
Start(u64),
Expand Down Expand Up @@ -62,7 +58,7 @@ impl From<std::io::SeekFrom> for SeekFrom {
///
/// - `WouldBlock` is removed, since `embedded-io` traits are always blocking. See the [crate-level documentation](crate) for details.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum ErrorKind {
/// Unspecified error kind.
Expand Down Expand Up @@ -229,7 +225,7 @@ impl<T: ?Sized + ErrorType> ErrorType for &mut T {

/// Error returned by [`Read::read_exact`]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ReadExactError<E> {
/// An EOF error was encountered before reading the exact amount of requested bytes.
UnexpectedEof,
Expand Down Expand Up @@ -267,7 +263,7 @@ impl<E: fmt::Debug> core::error::Error for ReadExactError<E> {}

/// Errors that could be returned by `Write` on `&mut [u8]`.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum SliceWriteError {
/// The target slice was full and so could not receive any new data.
Expand All @@ -276,7 +272,7 @@ pub enum SliceWriteError {

/// Error returned by [`Write::write_fmt`]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum WriteFmtError<E> {
/// An error was encountered while formatting.
FmtError,
Expand Down