Skip to content

Commit 6d83939

Browse files
authored
Merge pull request #481 from Dirbaio/embedded-io-release
io: add defmt support, release v0.5
2 parents a94b507 + 6ea5659 commit 6d83939

File tree

8 files changed

+40
-5
lines changed

8 files changed

+40
-5
lines changed

embedded-io-adapters/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## 0.5.0 - 2023-08-06
9+
10+
- First release

embedded-io-adapters/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "embedded-io-adapters"
3-
version = "0.1.0"
3+
version = "0.5.0"
44
edition = "2021"
55
description = "Adapters between the `embedded-io` traits and other I/O traits"
66
repository = "https://github.com/rust-embedded/embedded-hal"

embedded-io-adapters/src/std.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl<T: std::io::Seek + ?Sized> embedded_io::Seek for FromStd<T> {
6666
}
6767

6868
/// Adapter to `std::io` traits.
69+
#[derive(Clone)]
6970
pub struct ToStd<T: ?Sized> {
7071
inner: T,
7172
}

embedded-io-async/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## 0.5.0 - 2023-08-06
9+
10+
- First release

embedded-io-async/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ categories = [
1414
[features]
1515
std = ["alloc", "embedded-io/std"]
1616
alloc = ["embedded-io/alloc"]
17+
defmt-03 = ["dep:defmt-03", "embedded-io/defmt-03"]
1718

1819
[dependencies]
1920
embedded-io = { version = "0.5", path = "../embedded-io" }
21+
defmt-03 = { package = "defmt", version = "0.3", optional = true }
2022

2123
[package.metadata.docs.rs]
2224
features = ["std"]

embedded-io/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## Unreleased
8+
## 0.5.0 - 2023-08-06
99

1010
- Add `ReadReady`, `WriteReady` traits. They allow peeking whether the I/O handle is ready to read/write, so they allow using the traits in a non-blocking way.
1111
- Add variants to `ErrorKind` mirroring `std::io::ErrorKind`.
1212
- Add `From` impls to convert between `ErrorKind` and `std::io::ErrorKind`.
1313
- Moved `embedded_io::blocking` to the crate root.
1414
- Split async traits to the `embedded-io-async` crate.
1515
- Split trait adapters to the `embedded-io-adapters` crate.
16-
- Add `std::io` impls for `ReadExactError` & `WriteAllError`.
16+
- Add `std::error` impls for `ReadExactError` & `WriteAllError`.
1717
- Rename trait `Io` to `ErrorKind`, for consistency with `embedded-hal`.
1818

1919
## 0.4.0 - 2022-11-25

embedded-io/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ categories = [
1515
std = ["alloc"]
1616
alloc = []
1717

18+
[dependencies]
19+
defmt-03 = { package = "defmt", version = "0.3", optional = true }
20+
1821
[package.metadata.docs.rs]
1922
features = ["std"]
2023
rustdoc-args = ["--cfg", "docsrs"]

embedded-io/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
use core::fmt;
77

8+
// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`.
9+
#[cfg(feature = "defmt-03")]
10+
use defmt_03 as defmt;
11+
812
#[cfg(feature = "alloc")]
913
extern crate alloc;
1014

@@ -14,6 +18,7 @@ mod impls;
1418
///
1519
/// This is the `embedded-io` equivalent of [`std::io::SeekFrom`].
1620
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
21+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
1722
pub enum SeekFrom {
1823
/// Sets the offset to the provided number of bytes.
1924
Start(u64),
@@ -47,8 +52,6 @@ impl From<std::io::SeekFrom> for SeekFrom {
4752
}
4853
}
4954

50-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
51-
#[non_exhaustive]
5255
/// Possible kinds of errors.
5356
///
5457
/// This list is intended to grow over time and it is not recommended to
@@ -59,6 +62,9 @@ impl From<std::io::SeekFrom> for SeekFrom {
5962
///
6063
/// - `WouldBlock` is removed, since `embedded-io` traits are always blocking. See the [crate-level documentation](crate) for details.
6164
/// - `WriteZero` is removed, since it is a separate variant in [`WriteAllError`] and [`WriteFmtError`].
65+
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
66+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
67+
#[non_exhaustive]
6268
pub enum ErrorKind {
6369
/// Unspecified error kind.
6470
Other,
@@ -214,6 +220,7 @@ impl<T: ?Sized + ErrorType> ErrorType for &mut T {
214220

215221
/// Error returned by [`Read::read_exact`]
216222
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
223+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
217224
pub enum ReadExactError<E> {
218225
/// An EOF error was encountered before reading the exact amount of requested bytes.
219226
UnexpectedEof,
@@ -266,6 +273,7 @@ impl<E: fmt::Debug> std::error::Error for ReadExactError<E> {}
266273

267274
/// Error returned by [`Write::write_fmt`]
268275
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
276+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
269277
pub enum WriteFmtError<E> {
270278
/// [`Write::write`] wrote zero bytes
271279
WriteZero,
@@ -293,6 +301,7 @@ impl<E: fmt::Debug> std::error::Error for WriteFmtError<E> {}
293301

294302
/// Error returned by [`Write::write_all`]
295303
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
304+
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
296305
pub enum WriteAllError<E> {
297306
/// [`Write::write`] wrote zero bytes
298307
WriteZero,

0 commit comments

Comments
 (0)