Skip to content

Commit

Permalink
Merge pull request #481 from Dirbaio/embedded-io-release
Browse files Browse the repository at this point in the history
io: add defmt support, release v0.5
  • Loading branch information
eldruin authored Aug 7, 2023
2 parents a94b507 + 6ea5659 commit 6d83939
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
10 changes: 10 additions & 0 deletions embedded-io-adapters/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.0 - 2023-08-06

- First release
2 changes: 1 addition & 1 deletion embedded-io-adapters/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "embedded-io-adapters"
version = "0.1.0"
version = "0.5.0"
edition = "2021"
description = "Adapters between the `embedded-io` traits and other I/O traits"
repository = "https://github.com/rust-embedded/embedded-hal"
Expand Down
1 change: 1 addition & 0 deletions embedded-io-adapters/src/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl<T: std::io::Seek + ?Sized> embedded_io::Seek for FromStd<T> {
}

/// Adapter to `std::io` traits.
#[derive(Clone)]
pub struct ToStd<T: ?Sized> {
inner: T,
}
Expand Down
10 changes: 10 additions & 0 deletions embedded-io-async/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.0 - 2023-08-06

- First release
2 changes: 2 additions & 0 deletions embedded-io-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ categories = [
[features]
std = ["alloc", "embedded-io/std"]
alloc = ["embedded-io/alloc"]
defmt-03 = ["dep:defmt-03", "embedded-io/defmt-03"]

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

[package.metadata.docs.rs]
features = ["std"]
Expand Down
4 changes: 2 additions & 2 deletions embedded-io/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## 0.5.0 - 2023-08-06

- 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.
- Add variants to `ErrorKind` mirroring `std::io::ErrorKind`.
- Add `From` impls to convert between `ErrorKind` and `std::io::ErrorKind`.
- Moved `embedded_io::blocking` to the crate root.
- Split async traits to the `embedded-io-async` crate.
- Split trait adapters to the `embedded-io-adapters` crate.
- Add `std::io` impls for `ReadExactError` & `WriteAllError`.
- Add `std::error` impls for `ReadExactError` & `WriteAllError`.
- Rename trait `Io` to `ErrorKind`, for consistency with `embedded-hal`.

## 0.4.0 - 2022-11-25
Expand Down
3 changes: 3 additions & 0 deletions embedded-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ categories = [
std = ["alloc"]
alloc = []

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

[package.metadata.docs.rs]
features = ["std"]
rustdoc-args = ["--cfg", "docsrs"]
13 changes: 11 additions & 2 deletions embedded-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

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 @@ -14,6 +18,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))]
pub enum SeekFrom {
/// Sets the offset to the provided number of bytes.
Start(u64),
Expand Down Expand Up @@ -47,8 +52,6 @@ impl From<std::io::SeekFrom> for SeekFrom {
}
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[non_exhaustive]
/// Possible kinds of errors.
///
/// This list is intended to grow over time and it is not recommended to
Expand All @@ -59,6 +62,9 @@ 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.
/// - `WriteZero` is removed, since it is a separate variant in [`WriteAllError`] and [`WriteFmtError`].
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
#[non_exhaustive]
pub enum ErrorKind {
/// Unspecified error kind.
Other,
Expand Down Expand Up @@ -214,6 +220,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))]
pub enum ReadExactError<E> {
/// An EOF error was encountered before reading the exact amount of requested bytes.
UnexpectedEof,
Expand Down Expand Up @@ -266,6 +273,7 @@ impl<E: fmt::Debug> std::error::Error for ReadExactError<E> {}

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

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

0 comments on commit 6d83939

Please sign in to comment.