pub struct Time<'a> { /* private fields */ }Expand description
Time utilities accessor for RuntimeContext
Durations are plain core::time::Duration; instants are Stamps
on the context’s clock.
Implementations§
Source§impl Time<'_>
impl Time<'_>
Sourcepub fn now(&self) -> Stamp
pub fn now(&self) -> Stamp
Monotonic reading of the context’s clock: inside an instance, time since the instance started, on the clock that stamps writes.
Sourcepub fn unix_time(&self) -> Option<(u64, u32)>
pub fn unix_time(&self) -> Option<(u64, u32)>
Wall-clock time as (seconds, nanoseconds) since the Unix epoch, if
the runtime has a real-time clock (None on e.g. a bare MCU without
an RTC anchor). May be adjusted; unrelated to now.
Sourcepub fn sleep(&self, duration: Duration) -> BoxFuture
pub fn sleep(&self, duration: Duration) -> BoxFuture
Completes after at least duration has elapsed.
The future is boxed (it crosses the dyn RuntimeOps boundary), so each
call costs one small heap allocation. That is fine for periodic loops
and timeouts; in a no_std hot path that sleeps every iteration, await
the adapter’s native timer (e.g. embassy_time::Timer) directly
instead.
Sourcepub fn sleep_millis(&self, ms: u64) -> BoxFuture
pub fn sleep_millis(&self, ms: u64) -> BoxFuture
Convenience: sleep for ms milliseconds.
Sourcepub fn sleep_secs(&self, secs: u64) -> BoxFuture
pub fn sleep_secs(&self, secs: u64) -> BoxFuture
Convenience: sleep for secs seconds.