File tree Expand file tree Collapse file tree 5 files changed +31
-125
lines changed Expand file tree Collapse file tree 5 files changed +31
-125
lines changed Original file line number Diff line number Diff line change
1
+ //! Asynchronous Delays
2
+ //!
3
+ //! # What's the difference this trait and the `timer::CountDown` trait?
4
+ //!
5
+ //! The `Delay` trait provides an asynchronous delay abstraction and it's meant to be used either
6
+ //! to build higher-level abstractions like I/O timeouts or by itself.
7
+
8
+ use core:: future:: Future ;
9
+
10
+ /// Asynchronously wait a duration of time.
11
+ pub trait Delay {
12
+ /// Enumeration of `Delay` errors.
13
+ type Error ;
14
+
15
+ /// The future returned from `delay`.
16
+ type DelayFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
17
+ where
18
+ Self : ' a ;
19
+
20
+ /// The unit of time used by this delay timer.
21
+ type Time ;
22
+
23
+ /// Returns a future that will resolve when `duration` has passed.
24
+ /// It is not guaranteed that _exactly_ `duration` will pass, but it will
25
+ /// be `duration` or longer.
26
+ fn delay < ' a > ( & mut self , duration : impl Into < Self :: Time > ) -> Self :: DelayFuture < ' a > ;
27
+ }
Original file line number Diff line number Diff line change 3
3
//! This traits use `core::future::Future` and generic associated types.
4
4
5
5
pub mod i2c;
6
- pub mod rng;
7
6
pub mod serial;
8
7
pub mod spi;
9
- pub mod timer ;
8
+ pub mod delay ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ pub trait TransferInPlace<W: 'static> {
31
31
/// This method uses a single `readwrite` buffer.
32
32
///
33
33
/// The returned buffer is the initialized `readwrite` buffer.
34
- fn transfer_inplace < ' a > ( & ' a mut self , readwrite : & ' a mut [ W ] ) -> Self :: TransferInPlaceFuture < ' a > ;
34
+ fn transfer_inplace < ' a > ( & ' a mut self , words : & ' a mut [ W ] ) -> Self :: TransferInPlaceFuture < ' a > ;
35
35
}
36
36
37
37
/// Async write
@@ -45,7 +45,7 @@ pub trait Write<W> {
45
45
Self : ' a ;
46
46
47
47
/// Writes `words` to the slave, ignoring all the incoming words
48
- fn write < ' a > ( & ' a mut self , words : & ' a [ W ] ) -> Self :: WriteFuture < ' a > ;
48
+ fn write < ' a > ( & ' a mut self , write : & ' a [ W ] ) -> Self :: WriteFuture < ' a > ;
49
49
}
50
50
51
51
/// Async read
@@ -63,5 +63,5 @@ pub trait Read<W: 'static> {
63
63
/// by this trait. Some hardware can configure what values (e.g. 0x00, 0xFF), some cannot.
64
64
///
65
65
/// The returned buffer is the initialized `words` buffer.
66
- fn read < ' a > ( & ' a mut self , words : & ' a mut [ W ] ) -> Self :: ReadFuture < ' a > ;
66
+ fn read < ' a > ( & ' a mut self , read : & ' a mut [ W ] ) -> Self :: ReadFuture < ' a > ;
67
67
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments