Skip to main content

Clock

Trait Clock 

Source
pub trait Clock:
    Send
    + Sync
    + 'static {
    // Required methods
    fn wall_ms(&self) -> i64;
    fn elapsed(&self) -> Duration;

    // Provided method
    fn elapsed_ms(&self) -> i64 { ... }
}
Expand description

Separates wall timestamps from monotonic elapsed time.

Wall time stamps frames and invalidation markers. Elapsed time governs deadlines and process-local expiry. Timers live on the Runtime.

Required Methods§

Source

fn wall_ms(&self) -> i64

Epoch milliseconds from the application wall clock.

Source

fn elapsed(&self) -> Duration

Monotonic elapsed time since this clock’s origin, with native precision.

Provided Methods§

Source

fn elapsed_ms(&self) -> i64

Whole-millisecond elapsed reading used by process-local storage.

Insertion and lookup share this integer grid, so an entry inserted at 0.7 ms with a 1,000 ms TTL expires when this reading reaches 1,000.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§