embassy-time-driver

Crates

git

Versions

default

Flavors

embassy_time_driver

Trait Driver

Source
pub trait Driver:
    Send
    + Sync
    + 'static {
    // Required methods
    fn now(&self) -> u64;
    fn schedule_wake(&self, at: u64, waker: &Waker);
}
Expand description

Time driver

Required Methods§

Source

fn now(&self) -> u64

Return the current timestamp in ticks.

Implementations MUST ensure that:

  • This is guaranteed to be monotonic, i.e. a call to now() will always return a greater or equal value than earlier calls. Time can’t “roll backwards”.
  • It “never” overflows. It must not overflow in a sufficiently long time frame, say in 10_000 years (Human civilization is likely to already have self-destructed 10_000 years from now.). This means if your hardware only has 16bit/32bit timers you MUST extend them to 64-bit, for example by counting overflows in software, or chaining multiple timers together.
Source

fn schedule_wake(&self, at: u64, waker: &Waker)

Schedules a waker to be awoken at moment at. If this moment is in the past, the waker might be awoken immediately.

Implementors§