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 33//! This traits use `core::future::Future` and generic associated types.
44
55pub mod i2c;
6- pub mod rng;
76pub mod serial;
87pub 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> {
3131 /// This method uses a single `readwrite` buffer.
3232 ///
3333 /// 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 > ;
3535}
3636
3737/// Async write
@@ -45,7 +45,7 @@ pub trait Write<W> {
4545 Self : ' a ;
4646
4747 /// 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 > ;
4949}
5050
5151/// Async read
@@ -63,5 +63,5 @@ pub trait Read<W: 'static> {
6363 /// by this trait. Some hardware can configure what values (e.g. 0x00, 0xFF), some cannot.
6464 ///
6565 /// 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 > ;
6767}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments