From dfeab88d5e3d616a1e3d4fdd00fccac594e2d7b1 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 28 May 2021 23:39:21 +0200 Subject: [PATCH 1/4] blocking/serial: make method naming consistent --- src/blocking/serial.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/blocking/serial.rs b/src/blocking/serial.rs index 5c70fa352..5967414a1 100644 --- a/src/blocking/serial.rs +++ b/src/blocking/serial.rs @@ -10,13 +10,13 @@ pub trait Write { /// An implementation can choose to buffer the write, returning `Ok(())` /// after the complete slice has been written to a buffer, but before all /// words have been sent via the serial interface. To make sure that - /// everything has been sent, call [`bflush`] after this function returns. + /// everything has been sent, call [`flush`] after this function returns. /// - /// [`bflush`]: #tymethod.bflush - fn bwrite_all(&mut self, buffer: &[Word]) -> Result<(), Self::Error>; + /// [`flush`]: #tymethod.flush + fn write(&mut self, buffer: &[Word]) -> Result<(), Self::Error>; /// Block until the serial interface has sent all buffered words - fn bflush(&mut self) -> Result<(), Self::Error>; + fn flush(&mut self) -> Result<(), Self::Error>; } /// Blocking serial write @@ -38,7 +38,7 @@ pub mod write { { type Error = S::Error; - fn bwrite_all(&mut self, buffer: &[Word]) -> Result<(), Self::Error> { + fn write(&mut self, buffer: &[Word]) -> Result<(), Self::Error> { for word in buffer { nb::block!(self.write(word.clone()))?; } @@ -46,7 +46,7 @@ pub mod write { Ok(()) } - fn bflush(&mut self) -> Result<(), Self::Error> { + fn flush(&mut self) -> Result<(), Self::Error> { nb::block!(self.flush())?; Ok(()) } From 5ff8d54457b071f4156a3270810019e5d40155af Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 29 Jun 2021 20:39:52 +0200 Subject: [PATCH 2/4] Add changelog entry. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2616fa700..fb9e7f0a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Moved all traits into two modules depending on the execution model: `blocking` and `nb` (non-blocking). - Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of importing the `nb` crate directly in dependendent crates. +- `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush. ## [v1.0.0-alpha.4] - 2020-11-11 From 5144d21b35aab07ffb1eece12e85bb06f8861e24 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 15 Jun 2021 21:20:36 +0200 Subject: [PATCH 3/4] Remove prelude. --- src/blocking/pwm.rs | 2 +- src/blocking/qei.rs | 3 ++- src/lib.rs | 8 ++++---- src/nb/capture.rs | 2 +- src/nb/timer.rs | 2 +- src/prelude.rs | 40 ---------------------------------------- 6 files changed, 9 insertions(+), 48 deletions(-) delete mode 100644 src/prelude.rs diff --git a/src/blocking/pwm.rs b/src/blocking/pwm.rs index ed02a17d7..3dee5d770 100644 --- a/src/blocking/pwm.rs +++ b/src/blocking/pwm.rs @@ -9,7 +9,7 @@ /// ``` /// extern crate embedded_hal as hal; /// -/// use hal::prelude::*; +/// use hal::blocking::pwm::Pwm; /// /// fn main() { /// let mut pwm: Pwm1 = { diff --git a/src/blocking/qei.rs b/src/blocking/qei.rs index fc5e732bb..2fdc1733a 100644 --- a/src/blocking/qei.rs +++ b/src/blocking/qei.rs @@ -11,7 +11,8 @@ /// #[macro_use(block)] /// extern crate nb; /// -/// use hal::prelude::*; +/// use hal::blocking::qei::Qei; +/// use hal::nb::timer::CountDown; /// /// fn main() { /// let mut qei: Qei1 = { diff --git a/src/lib.rs b/src/lib.rs index 2ce5b13a2..1dbb6dd49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -244,7 +244,7 @@ //! ``` //! use embedded_hal as hal; //! use nb::block; -//! use hal::prelude::*; +//! use hal::nb::serial::Write; //! //! fn write_all(serial: &mut S, buffer: &[u8]) -> Result<(), S::Error> //! where @@ -266,7 +266,8 @@ //! use embedded_hal as hal; //! use nb; //! -//! use hal::prelude::*; +//! use hal::nb::serial::Write; +//! use hal::nb::timer::CountDown; //! //! enum Error { //! /// Serial interface error @@ -320,7 +321,7 @@ //! use embedded_hal as hal; //! use nb; //! -//! use hal::prelude::*; +//! use hal::nb::serial::Write; //! use ::core::convert::Infallible; //! //! fn flush(serial: &mut S, cb: &mut CircularBuffer) @@ -411,7 +412,6 @@ pub mod blocking; pub mod fmt; pub mod nb; -pub mod prelude; mod private { use crate::blocking::i2c::{SevenBitAddress, TenBitAddress}; diff --git a/src/nb/capture.rs b/src/nb/capture.rs index 6feee5b48..3e1cea29e 100644 --- a/src/nb/capture.rs +++ b/src/nb/capture.rs @@ -12,7 +12,7 @@ /// #[macro_use(block)] /// extern crate nb; /// -/// use hal::prelude::*; +/// use hal::nb::capture::Capture; /// /// fn main() { /// let mut capture: Capture1 = { diff --git a/src/nb/timer.rs b/src/nb/timer.rs index 38246a768..07a1b02de 100644 --- a/src/nb/timer.rs +++ b/src/nb/timer.rs @@ -19,7 +19,7 @@ /// #[macro_use(block)] /// extern crate nb; /// -/// use hal::prelude::*; +/// use hal::nb::timer::CountDown; /// /// fn main() { /// let mut led: Led = { diff --git a/src/prelude.rs b/src/prelude.rs deleted file mode 100644 index 7ea09b34d..000000000 --- a/src/prelude.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! The prelude is a collection of all the traits in this crate -//! -//! The traits have been renamed to avoid collisions with other items when -//! performing a glob import. - -pub use crate::blocking::delay::DelayMs as _embedded_hal_blocking_delay_DelayMs; -pub use crate::blocking::delay::DelayUs as _embedded_hal_blocking_delay_DelayUs; -pub use crate::blocking::digital::InputPin as _embedded_hal_blocking_digital_InputPin; -pub use crate::blocking::digital::OutputPin as _embedded_hal_blocking_digital_OutputPin; -pub use crate::blocking::digital::StatefulOutputPin as _embedded_hal_blocking_digital_StatefulOutputPin; -pub use crate::blocking::digital::ToggleableOutputPin as _embedded_hal_blocking_digital_ToggleableOutputPin; -pub use crate::blocking::i2c::{ - Read as _embedded_hal_blocking_i2c_Read, - Transactional as _embedded_hal_blocking_i2c_Transactional, - Write as _embedded_hal_blocking_i2c_Write, WriteIter as _embedded_hal_blocking_i2c_WriteIter, - WriteIterRead as _embedded_hal_blocking_i2c_WriteIterRead, - WriteRead as _embedded_hal_blocking_i2c_WriteRead, -}; -pub use crate::blocking::pwm::Pwm as _embedded_hal_blocking_Pwm; -pub use crate::blocking::pwm::PwmPin as _embedded_hal_blocking_PwmPin; -pub use crate::blocking::qei::Qei as _embedded_hal_blocking_Qei; -pub use crate::blocking::rng::Read as _embedded_hal_blocking_rng_Read; -pub use crate::blocking::serial::Write as _embedded_hal_blocking_serial_Write; -pub use crate::blocking::spi::{ - Transfer as _embedded_hal_blocking_spi_Transfer, Write as _embedded_hal_blocking_spi_Write, - WriteIter as _embedded_hal_blocking_spi_WriteIter, -}; -pub use crate::blocking::watchdog::Disable as _embedded_hal_blocking_watchdog_Disable; -pub use crate::blocking::watchdog::Enable as _embedded_hal_blocking_watchdog_Enable; -pub use crate::blocking::watchdog::Watchdog as _embedded_hal_blocking_watchdog_Watchdog; -pub use crate::nb::adc::Channel as _embedded_hal_nb_adc_Channel; -pub use crate::nb::adc::OneShot as _embedded_hal_nb_adc_OneShot; -pub use crate::nb::capture::Capture as _embedded_hal_nb_Capture; -pub use crate::nb::rng::Read as _embedded_hal_nb_rng_Read; -pub use crate::nb::serial::Read as _embedded_hal_nb_serial_Read; -pub use crate::nb::serial::Write as _embedded_hal_nb_serial_Write; -pub use crate::nb::spi::FullDuplex as _embedded_hal_nb_spi_FullDuplex; -pub use crate::nb::timer::Cancel as _embedded_hal_nb_timer_Cancel; -pub use crate::nb::timer::CountDown as _embedded_hal_nb_timer_CountDown; -pub use crate::nb::timer::Periodic as _embedded_hal_nb_timer_Periodic; From b6419e39f8df5c6401f84043b69aad528914bc3d Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 29 Jun 2021 20:49:22 +0200 Subject: [PATCH 4/4] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb9e7f0a3..5bad28bff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of importing the `nb` crate directly in dependendent crates. - `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush. +- Removed `prelude` to avoid method name conflicts between different flavors (blocking, nb) of the same trait. Traits must now be manually imported. ## [v1.0.0-alpha.4] - 2020-11-11