diff options
Diffstat (limited to 'embassy-time/src/timer.rs')
| -rw-r--r-- | embassy-time/src/timer.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index d1162eadd..fcf79f58e 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -2,8 +2,8 @@ use core::future::{poll_fn, Future}; | |||
| 2 | use core::pin::Pin; | 2 | use core::pin::Pin; |
| 3 | use core::task::{Context, Poll}; | 3 | use core::task::{Context, Poll}; |
| 4 | 4 | ||
| 5 | use futures_util::stream::FusedStream; | 5 | use futures_core::stream::FusedStream; |
| 6 | use futures_util::Stream; | 6 | use futures_core::Stream; |
| 7 | 7 | ||
| 8 | use crate::{Duration, Instant}; | 8 | use crate::{Duration, Instant}; |
| 9 | 9 | ||
| @@ -66,6 +66,8 @@ impl<F: Future> WithTimeout for F { | |||
| 66 | 66 | ||
| 67 | /// Future for the [`with_timeout`] and [`with_deadline`] functions. | 67 | /// Future for the [`with_timeout`] and [`with_deadline`] functions. |
| 68 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 68 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 69 | #[derive(Debug)] | ||
| 70 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 69 | pub struct TimeoutFuture<F> { | 71 | pub struct TimeoutFuture<F> { |
| 70 | timer: Timer, | 72 | timer: Timer, |
| 71 | fut: F, | 73 | fut: F, |
| @@ -92,6 +94,8 @@ impl<F: Future> Future for TimeoutFuture<F> { | |||
| 92 | 94 | ||
| 93 | /// A future that completes at a specified [Instant](struct.Instant.html). | 95 | /// A future that completes at a specified [Instant](struct.Instant.html). |
| 94 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 96 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 97 | #[derive(Debug)] | ||
| 98 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 95 | pub struct Timer { | 99 | pub struct Timer { |
| 96 | expires_at: Instant, | 100 | expires_at: Instant, |
| 97 | yielded_once: bool, | 101 | yielded_once: bool, |
| @@ -99,6 +103,7 @@ pub struct Timer { | |||
| 99 | 103 | ||
| 100 | impl Timer { | 104 | impl Timer { |
| 101 | /// Expire at specified [Instant](struct.Instant.html) | 105 | /// Expire at specified [Instant](struct.Instant.html) |
| 106 | /// Will expire immediately if the Instant is in the past. | ||
| 102 | pub fn at(expires_at: Instant) -> Self { | 107 | pub fn at(expires_at: Instant) -> Self { |
| 103 | Self { | 108 | Self { |
| 104 | expires_at, | 109 | expires_at, |
| @@ -227,6 +232,8 @@ impl Future for Timer { | |||
| 227 | /// ## Cancel safety | 232 | /// ## Cancel safety |
| 228 | /// It is safe to cancel waiting for the next tick, | 233 | /// It is safe to cancel waiting for the next tick, |
| 229 | /// meaning no tick is lost if the Future is dropped. | 234 | /// meaning no tick is lost if the Future is dropped. |
| 235 | #[derive(Debug)] | ||
| 236 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 230 | pub struct Ticker { | 237 | pub struct Ticker { |
| 231 | expires_at: Instant, | 238 | expires_at: Instant, |
| 232 | duration: Duration, | 239 | duration: Duration, |
