diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-11-21 23:31:31 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-11-25 21:02:06 +0100 |
| commit | 1e2fb0459d8546ba658bb9fe150be5f1f537b48e (patch) | |
| tree | eb40a5027581896c7b78db58f509431ed6b11892 /embassy-nrf/src/gpiote.rs | |
| parent | 758f5d7ea29f1df14d5ef59c82e4b7f22545d775 (diff) | |
Switch to async-fn-in-trait
Diffstat (limited to 'embassy-nrf/src/gpiote.rs')
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 7f7468a20..7467dbc60 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -473,71 +473,49 @@ mod eh1 { | |||
| 473 | 473 | ||
| 474 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | 474 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 475 | mod eha { | 475 | mod eha { |
| 476 | use futures::FutureExt; | ||
| 477 | |||
| 478 | use super::*; | 476 | use super::*; |
| 479 | 477 | ||
| 480 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { | 478 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { |
| 481 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 479 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 482 | 480 | Ok(self.wait_for_high().await) | |
| 483 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { | ||
| 484 | self.wait_for_high().map(Ok) | ||
| 485 | } | 481 | } |
| 486 | 482 | ||
| 487 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 483 | async fn wait_for_low(&mut self) -> Result<(), Self::Error> { |
| 488 | 484 | Ok(self.wait_for_low().await) | |
| 489 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { | ||
| 490 | self.wait_for_low().map(Ok) | ||
| 491 | } | 485 | } |
| 492 | 486 | ||
| 493 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 487 | async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { |
| 494 | 488 | Ok(self.wait_for_rising_edge().await) | |
| 495 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { | ||
| 496 | self.wait_for_rising_edge().map(Ok) | ||
| 497 | } | 489 | } |
| 498 | 490 | ||
| 499 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 491 | async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { |
| 500 | 492 | Ok(self.wait_for_falling_edge().await) | |
| 501 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { | ||
| 502 | self.wait_for_falling_edge().map(Ok) | ||
| 503 | } | 493 | } |
| 504 | 494 | ||
| 505 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 495 | async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { |
| 506 | 496 | Ok(self.wait_for_any_edge().await) | |
| 507 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { | ||
| 508 | self.wait_for_any_edge().map(Ok) | ||
| 509 | } | 497 | } |
| 510 | } | 498 | } |
| 511 | 499 | ||
| 512 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { | 500 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { |
| 513 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 501 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 514 | 502 | Ok(self.wait_for_high().await) | |
| 515 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { | ||
| 516 | self.wait_for_high().map(Ok) | ||
| 517 | } | 503 | } |
| 518 | 504 | ||
| 519 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 505 | async fn wait_for_low(&mut self) -> Result<(), Self::Error> { |
| 520 | 506 | Ok(self.wait_for_low().await) | |
| 521 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { | ||
| 522 | self.wait_for_low().map(Ok) | ||
| 523 | } | 507 | } |
| 524 | 508 | ||
| 525 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 509 | async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { |
| 526 | 510 | Ok(self.wait_for_rising_edge().await) | |
| 527 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { | ||
| 528 | self.wait_for_rising_edge().map(Ok) | ||
| 529 | } | 511 | } |
| 530 | 512 | ||
| 531 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 513 | async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { |
| 532 | 514 | Ok(self.wait_for_falling_edge().await) | |
| 533 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { | ||
| 534 | self.wait_for_falling_edge().map(Ok) | ||
| 535 | } | 515 | } |
| 536 | 516 | ||
| 537 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 517 | async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { |
| 538 | 518 | Ok(self.wait_for_any_edge().await) | |
| 539 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { | ||
| 540 | self.wait_for_any_edge().map(Ok) | ||
| 541 | } | 519 | } |
| 542 | } | 520 | } |
| 543 | } | 521 | } |
