Skip to content

Commit b036e16

Browse files
bors[bot]Dirbaio
andauthored
Merge #432
432: delay: make infallible. r=therealprof a=Dirbaio 1.0 alphas have been out for a while, some HALs out there implement it. I haven't seen one with an actual fallible delay. I know the decision was made to make Delay fallible for consistency, but I think we should make one exception for just this one trait. Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents e8d94e9 + d3f8fe6 commit b036e16

File tree

4 files changed

+13
-21
lines changed

4 files changed

+13
-21
lines changed

embedded-hal-async/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Changed
11+
- delay: make infallible.
12+
1013
## [v0.2.0-alpha.0] - 2022-11-23
1114

1215
- Switch all traits to use [`async_fn_in_trait`](https://blog.rust-lang.org/inside-rust/2022/11/17/async-fn-in-trait-nightly.html) (AFIT). Requires `nightly-2022-11-22` or newer.

embedded-hal-async/src/delay.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,24 @@
22
33
/// Microsecond delay
44
pub trait DelayUs {
5-
/// Enumeration of errors
6-
type Error: core::fmt::Debug;
7-
85
/// Pauses execution for at minimum `us` microseconds. Pause can be longer
96
/// if the implementation requires it due to precision/timing issues.
10-
async fn delay_us(&mut self, us: u32) -> Result<(), Self::Error>;
7+
async fn delay_us(&mut self, us: u32);
118

129
/// Pauses execution for at minimum `ms` milliseconds. Pause can be longer
1310
/// if the implementation requires it due to precision/timing issues.
14-
async fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error>;
11+
async fn delay_ms(&mut self, ms: u32);
1512
}
1613

1714
impl<T> DelayUs for &mut T
1815
where
1916
T: DelayUs,
2017
{
21-
type Error = T::Error;
22-
23-
async fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
18+
async fn delay_us(&mut self, us: u32) {
2419
T::delay_us(self, us).await
2520
}
2621

27-
async fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
22+
async fn delay_ms(&mut self, ms: u32) {
2823
T::delay_ms(self, ms).await
2924
}
3025
}

embedded-hal/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Changed
1111
- gpio: add `ErrorKind` enum for consistency with other traits and for future extensibility. No kinds are defined for now.
12+
- delay: make infallible.
1213

1314
## [v1.0.0-alpha.9] - 2022-09-28
1415

embedded-hal/src/delay.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,28 @@
33
/// Microsecond delay
44
///
55
pub trait DelayUs {
6-
/// Enumeration of `DelayUs` errors
7-
type Error: core::fmt::Debug;
8-
96
/// Pauses execution for at minimum `us` microseconds. Pause can be longer
107
/// if the implementation requires it due to precision/timing issues.
11-
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error>;
8+
fn delay_us(&mut self, us: u32);
129

1310
/// Pauses execution for at minimum `ms` milliseconds. Pause can be longer
1411
/// if the implementation requires it due to precision/timing issues.
15-
fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
12+
fn delay_ms(&mut self, ms: u32) {
1613
for _ in 0..ms {
17-
self.delay_us(1000)?;
14+
self.delay_us(1000);
1815
}
19-
20-
Ok(())
2116
}
2217
}
2318

2419
impl<T> DelayUs for &mut T
2520
where
2621
T: DelayUs,
2722
{
28-
type Error = T::Error;
29-
30-
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
23+
fn delay_us(&mut self, us: u32) {
3124
T::delay_us(self, us)
3225
}
3326

34-
fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
27+
fn delay_ms(&mut self, ms: u32) {
3528
T::delay_ms(self, ms)
3629
}
3730
}

0 commit comments

Comments
 (0)