pub struct Time<'a> { /* private fields */ }Expand description
Time utilities accessor for RuntimeContext
Durations are plain core::time::Duration; instants are u64
nanoseconds from an arbitrary monotonic epoch (only differences between
two readings are meaningful).
Implementations§
Source§impl Time<'_>
impl Time<'_>
Sourcepub fn now(&self) -> u64
pub fn now(&self) -> u64
Monotonic clock reading in nanoseconds from an arbitrary epoch.
Never decreases; saturates at u64::MAX rather than wrapping.
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).
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.