From 0ef27cc6b0e59bf5d756b834e462d6d68c8cc471 Mon Sep 17 00:00:00 2001 From: Felix Wirth Date: Thu, 27 Jun 2024 23:14:28 +0200 Subject: [PATCH] rename feature `embedded_hal` to `embedded-hal-02` --- .github/workflows/quickstart.yml | 8 ++++---- CHANGELOG.md | 1 + Cargo.toml | 10 +++++----- src/lib.rs | 26 +++++++++++++------------- src/transport/decoder_reader.rs | 4 ++-- src/util.rs | 23 +++++++++++++---------- 6 files changed, 38 insertions(+), 34 deletions(-) diff --git a/.github/workflows/quickstart.yml b/.github/workflows/quickstart.yml index a72d651..0a1426c 100644 --- a/.github/workflows/quickstart.yml +++ b/.github/workflows/quickstart.yml @@ -25,10 +25,10 @@ jobs: - run: cargo test - run: cargo test --no-default-features - run: cargo test --no-default-features --features=alloc - - run: cargo test --no-default-features --features=embedded_hal - - run: cargo test --no-default-features --features=embedded_hal,alloc - - run: cargo test --no-default-features --features=embedded_hal,alloc,std - - run: cargo test --no-default-features --features=embedded_hal,alloc,std,serde + - run: cargo test --no-default-features --features=embedded-hal-02 + - run: cargo test --no-default-features --features=embedded-hal-02,alloc + - run: cargo test --no-default-features --features=embedded-hal-02,alloc,std + - run: cargo test --no-default-features --features=embedded-hal-02,alloc,std,serde build_examples: name: Build Examples diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e5f8b7..d9768dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Decoder improvements (#43) - **BREAKING:** Renamed `*Reader` types to `*ByteSource` (e.g. `IoReader` to `IoByteSource`) (#45) - Refactored `ByteSourceErr` trait (#46) +- **BREAKING:** Renamed feature `embedded_hal` to `embedded-hal-02` (#47) ## [0.4.0] - 2024-06-04 diff --git a/Cargo.toml b/Cargo.toml index 2187e9c..6db2e5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,14 +14,14 @@ edition = "2021" default = ["std"] std = ["alloc"] alloc = [] -embedded_hal = ["nb", "embedded-hal"] +embedded-hal-02 = ["nb", "dep:embedded-hal-02"] serde = ["dep:serde"] [dependencies] -crc = "3.0.0" -embedded-hal = { version = "0.2.7", optional = true } -nb = { version = "1.1.0", optional = true } -serde = { version = "1.0", features = ["derive"], optional = true } +crc = "3" +embedded-hal-02 = { version = "0.2", package = "embedded-hal", optional = true } +nb = { version = "1", optional = true } +serde = { version = "1", features = ["derive"], optional = true } [dev-dependencies] insta = { version = "1.21.0", features = ["yaml", "glob"] } diff --git a/src/lib.rs b/src/lib.rs index daee9cf..913eb3f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ //! # Feature flags //! - **`std`** (default) — Remove this feature to make the library `no_std` compatible. //! - **`alloc`** (default) — Implementations using allocations (`alloc::Vec` et al.). -//! - **`embedded_hal`** — Allows using pins implementing `embedded_hal::serial::Read` in [`SmlReader`](SmlReader::from_eh_reader). +//! - **`embedded-hal-02`** — Allows using pins implementing `embedded_hal::serial::Read` in [`SmlReader`](SmlReader::from_eh_reader). //! - **`nb`** - Enables non-blocking APIs using the `nb` crate. //! - **`serde`** - Implements `Serialize` and `Deserialize` on most error types. //! @@ -279,7 +279,7 @@ impl DummySmlReader { /// Build an `SmlReader` from a type implementing `embedded_hal::serial::Read`. /// - /// *This function is available only if sml-rs is built with the `"embedded-hal"` feature.* + /// *This function is available only if sml-rs is built with the `"embedded-hal-02"` feature.* /// /// # Examples /// @@ -288,7 +288,7 @@ impl DummySmlReader { /// // usually provided by hardware abstraction layers (HALs) for specific chips /// // let pin = ...; /// # struct Pin; - /// # impl embedded_hal::serial::Read for Pin { + /// # impl embedded_hal_02::serial::Read for Pin { /// # type Error = (); /// # fn read(&mut self) -> nb::Result { Ok(123) } /// # } @@ -296,10 +296,10 @@ impl DummySmlReader { /// /// let reader = SmlReader::from_eh_reader(pin); /// ``` - #[cfg(feature = "embedded_hal")] + #[cfg(feature = "embedded-hal-02")] pub fn from_eh_reader(reader: R) -> SmlReader, DefaultBuffer> where - R: embedded_hal::serial::Read, + R: embedded_hal_02::serial::Read, { SmlReader { decoder: DecoderReader::new(util::EhByteSource::new(reader)), @@ -429,7 +429,7 @@ where /// /// Using `nb::Result` allows this method to be awaited using the `nb::block!` macro. /// - /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded_hal"` features.* + /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded-hal-02"` features.* #[cfg(feature = "nb")] pub fn read_nb<'i, T>(&'i mut self) -> nb::Result where @@ -463,7 +463,7 @@ where /// /// Using `nb::Result` allows this method to be awaited using the `nb::block!` macro. /// - /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded_hal"` features.* + /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded-hal-02"` features.* #[cfg(feature = "nb")] pub fn next_nb<'i, T>(&'i mut self) -> nb::Result, T::Error> where @@ -518,7 +518,7 @@ impl SmlReaderBuilder { /// Build an `SmlReader` from a type implementing `embedded_hal::serial::Read`. /// - /// *This function is available only if sml-rs is built with the `"embedded-hal"` feature.* + /// *This function is available only if sml-rs is built with the `"embedded-hal-02"` feature.* /// /// # Examples /// @@ -527,7 +527,7 @@ impl SmlReaderBuilder { /// // usually provided by hardware abstraction layers (HALs) for specific chips /// // let pin = ...; /// # struct Pin; - /// # impl embedded_hal::serial::Read for Pin { + /// # impl embedded_hal_02::serial::Read for Pin { /// # type Error = (); /// # fn read(&mut self) -> nb::Result { Ok(123) } /// # } @@ -535,8 +535,8 @@ impl SmlReaderBuilder { /// /// let reader = SmlReader::with_static_buffer::<1024>().from_eh_reader(pin); /// ``` - #[cfg(feature = "embedded_hal")] - pub fn from_eh_reader, E>( + #[cfg(feature = "embedded-hal-02")] + pub fn from_eh_reader, E>( self, reader: R, ) -> SmlReader, Buf> { @@ -697,11 +697,11 @@ fn test_smlreader_construction() { } #[test] -#[cfg(feature = "embedded_hal")] +#[cfg(feature = "embedded-hal-02")] fn test_smlreader_eh_construction() { // dummy struct implementing `Read` struct Pin; - impl embedded_hal::serial::Read for Pin { + impl embedded_hal_02::serial::Read for Pin { type Error = i16; fn read(&mut self) -> nb::Result { diff --git a/src/transport/decoder_reader.rs b/src/transport/decoder_reader.rs index 3e53e5b..8b07a23 100644 --- a/src/transport/decoder_reader.rs +++ b/src/transport/decoder_reader.rs @@ -113,7 +113,7 @@ where /// /// Using `nb::Result` allows this method to be awaited using the `nb::block!` macro. /// - /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded_hal"` features.* + /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded-hal-02"` features.* #[cfg(feature = "nb")] pub fn read_nb(&mut self) -> nb::Result<&[u8], ReadDecodedError> { self.read().map_err(|e| match e { @@ -130,7 +130,7 @@ where /// /// Using `nb::Result` allows this method to be awaited using the `nb::block!` macro. /// - /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded_hal"` features.* + /// *This function is available only if sml-rs is built with the `"nb"` or `"embedded-hal-02"` features.* #[cfg(feature = "nb")] pub fn next_nb(&mut self) -> nb::Result, ReadDecodedError> { match self.read_nb() { diff --git a/src/util.rs b/src/util.rs index c160771..99a95f3 100644 --- a/src/util.rs +++ b/src/util.rs @@ -245,28 +245,28 @@ impl ByteSourceErr for std::io::Error { impl private::Sealed for std::io::Error {} /// Wraps types that implement `embedded_hal::serial::Read<...>` and implements `ByteSource` -#[cfg(feature = "embedded_hal")] +#[cfg(feature = "embedded-hal-02")] pub struct EhByteSource where - R: embedded_hal::serial::Read, + R: embedded_hal_02::serial::Read, { inner: R, } -#[cfg(feature = "embedded_hal")] +#[cfg(feature = "embedded-hal-02")] impl EhByteSource where - R: embedded_hal::serial::Read, + R: embedded_hal_02::serial::Read, { pub(crate) fn new(reader: R) -> Self { EhByteSource { inner: reader } } } -#[cfg(feature = "embedded_hal")] +#[cfg(feature = "embedded-hal-02")] impl ByteSource for EhByteSource where - R: embedded_hal::serial::Read, + R: embedded_hal_02::serial::Read, { type ReadError = nb::Error; @@ -275,10 +275,13 @@ where } } -#[cfg(feature = "embedded_hal")] -impl private::Sealed for EhByteSource where R: embedded_hal::serial::Read {} +#[cfg(feature = "embedded-hal-02")] +impl private::Sealed for EhByteSource where + R: embedded_hal_02::serial::Read +{ +} -#[cfg(feature = "embedded_hal")] +#[cfg(feature = "embedded-hal-02")] impl ByteSourceErr for nb::Error { fn kind(&self) -> ErrKind { match self { @@ -288,7 +291,7 @@ impl ByteSourceErr for nb::Error { } } -#[cfg(feature = "embedded_hal")] +#[cfg(feature = "embedded-hal-02")] impl private::Sealed for nb::Error {} /// Error type indicating that the end of the input has been reached