aboutsummaryrefslogtreecommitdiff
path: root/embassy-time/src/timer.rs
diff options
context:
space:
mode:
author1-rafael-1 <[email protected]>2025-09-15 20:07:18 +0200
committer1-rafael-1 <[email protected]>2025-09-15 20:07:18 +0200
commit6bb3d2c0720fa082f27d3cdb70f516058497ec87 (patch)
tree5a1e255cff999b00800f203b91a759c720c973e5 /embassy-time/src/timer.rs
parenteb685574601d98c44faed9a3534d056199b46e20 (diff)
parent92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff)
Merge branch 'main' into rp2040-rtc-alarm
Diffstat (limited to 'embassy-time/src/timer.rs')
-rw-r--r--embassy-time/src/timer.rs11
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};
2use core::pin::Pin; 2use core::pin::Pin;
3use core::task::{Context, Poll}; 3use core::task::{Context, Poll};
4 4
5use futures_util::stream::FusedStream; 5use futures_core::stream::FusedStream;
6use futures_util::Stream; 6use futures_core::Stream;
7 7
8use crate::{Duration, Instant}; 8use 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))]
69pub struct TimeoutFuture<F> { 71pub 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))]
95pub struct Timer { 99pub 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
100impl Timer { 104impl 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))]
230pub struct Ticker { 237pub struct Ticker {
231 expires_at: Instant, 238 expires_at: Instant,
232 duration: Duration, 239 duration: Duration,