Skip to content

Commit

Permalink
Merge #324
Browse files Browse the repository at this point in the history
324: Remove traits with unconstrained `Time` associated types. r=eldruin a=Dirbaio

As discussed in #201 and
#177 (comment) ,
the traits that have an unconstrained `type Time` associated type end up
not being usable for HAL-independent drivers in practice, since there is too
much variation across HALs of what the actual Time type is.

These should be bound to something, probably a `Duration` trait, so that
drivers can actually create and use them. Alternatively embedded-hal could have
actual `struct Duration` and so.

Either way, it's unclear what the final solution would look like. We shouldn't leave
these traits in the 1.0 release, since fixing them later will be a breaking change.
We should temporarily remove them, and add them back once we have figured this out
which won't be a breaking change.

Co-authored-by: Dario Nieuwenhuis <[email protected]>
  • Loading branch information
bors[bot] and Dirbaio authored Feb 9, 2022
2 parents c90fc2a + 513807e commit 2f5d994
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 605 deletions.
130 changes: 0 additions & 130 deletions src/capture.rs

This file was deleted.

58 changes: 0 additions & 58 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,60 +258,6 @@
//! # fn main() {}
//! ```
//!
//! - Blocking serial read with timeout
//!
//! ```
//! use embedded_hal as hal;
//! use hal::nb;
//!
//! use hal::serial::nb::Write;
//! use hal::timer::nb::CountDown;
//!
//! enum Error<SE, TE> {
//! /// Serial interface error
//! Serial(SE),
//! /// Timeout error
//! TimedOut(TE),
//! }
//!
//! fn read_with_timeout<S, T>(
//! serial: &mut S,
//! timer: &mut T,
//! timeout: T::Time,
//! ) -> Result<u8, Error<S::Error, T::Error>>
//! where
//! T: hal::timer::nb::CountDown<Error = ()>,
//! S: hal::serial::nb::Read<u8>,
//! {
//! timer.start(timeout).map_err(Error::TimedOut)?;
//!
//! loop {
//! match serial.read() {
//! // raise error
//! Err(nb::Error::Other(e)) => return Err(Error::Serial(e)),
//! Err(nb::Error::WouldBlock) => {
//! // no data available yet, check the timer below
//! },
//! Ok(byte) => return Ok(byte),
//! }
//!
//! match timer.wait() {
//! Err(nb::Error::Other(e)) => {
//! // The error type specified by `timer.wait()` is `!`, which
//! // means no error can actually occur. The Rust compiler
//! // still forces us to provide this match arm, though.
//! unreachable!()
//! },
//! // no timeout yet, try again
//! Err(nb::Error::WouldBlock) => continue,
//! Ok(()) => return Err(Error::TimedOut(())),
//! }
//! }
//! }
//!
//! # fn main() {}
//! ```
//!
//! - Buffered serial interface with periodic flushing in interrupt handler
//!
//! ```
Expand Down Expand Up @@ -411,16 +357,12 @@ pub mod fmt;
pub use nb;
pub mod adc;
pub mod can;
pub mod capture;
pub mod delay;
pub mod digital;
pub mod i2c;
pub mod pwm;
pub mod qei;
pub mod serial;
pub mod spi;
pub mod timer;
pub mod watchdog;

mod private {
use crate::i2c::{SevenBitAddress, TenBitAddress};
Expand Down
Loading

0 comments on commit 2f5d994

Please sign in to comment.