Skip to content

Commit 41af589

Browse files
committed
Add futures::digital::AsyncInputPin trait
1 parent 4d02ea1 commit 41af589

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/futures/digital.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Asynchronous digital I/O
2+
3+
use core::future::Future;
4+
5+
/// Asynchronously wait for a pin to become high or low.
6+
pub trait AsyncInputPin {
7+
/// The future returned by the `until_high` function.
8+
type UntilHighFuture<'a>: Future<Output=()> + 'a;
9+
10+
/// The future returned by the `until_low` function.
11+
type UntilLowFuture<'a>: Future<Output=()> + 'a;
12+
13+
/// Returns a future that resolves when this pin becomes high.
14+
fn until_high<'a>(&self) -> Self::UntilHighFuture<'a>;
15+
16+
/// Returns a future that resolves when this pin becomes high.
17+
fn until_low<'a>(&self) -> Self::UntilLowFuture<'a>;
18+
}

src/futures/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ pub mod i2c;
66
pub mod serial;
77
pub mod spi;
88
pub mod delay;
9+
pub mod digital;

0 commit comments

Comments
 (0)