api::timer
Timer services.
Provides now_ms() for wall-clock time, once_ms() for one-shot
callbacks, every_ms() for periodic callbacks, and cancel() to
stop a pending timer.
Example
Section titled “Example”use api::timer::{once_ms, now_ms};
fn callback() { /* ... */ }
let start = now_ms();let handle = once_ms(100, callback);Structs
Section titled “Structs”TimerHandle
Section titled “TimerHandle”struct TimerHandle(u32);Opaque handle returned by [once_ms] / [every_ms].
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq
Functions
Section titled “Functions”cancel
Section titled “cancel”fn cancel(handle: TimerHandle)Cancel a timer.
References: TimerHandle
every_ms
Section titled “every_ms”fn every_ms(ms: u32, callback: fn(..)) -> TimerHandleSchedule a repeating callback every ms milliseconds.
References: TimerHandle
now_ms
Section titled “now_ms”fn now_ms() -> u64Return the current tick count (milliseconds since boot).
once_ms
Section titled “once_ms”fn once_ms(ms: u32, callback: fn(..)) -> TimerHandleSchedule a one-shot callback after ms milliseconds.
References: TimerHandle