Skip to main content

Clock

Trait Clock 

pub trait Clock:
    Send
    + Sync
    + Debug {
    // Required method
    fn now_millis(&self) -> u64;
}
Expand description

A source of milliseconds.

Implementations must be cheap to call (it happens on every report) and must never panic. The absolute epoch is deliberately unspecified: atune only ever computes differences and compares against caller-supplied deadlines, so a clock that starts at zero is as valid as one that returns Unix time.

Monotonicity is expected but not enforced; consumers must tolerate a backwards step (for instance by saturating the subtraction) rather than panicking.

Required Methods§

fn now_millis(&self) -> u64

The current time, in milliseconds since this clock’s epoch.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

§

impl<C> Clock for &C
where C: Clock + ?Sized,

§

fn now_millis(&self) -> u64

§

impl<C> Clock for Arc<C>
where C: Clock + ?Sized,

§

fn now_millis(&self) -> u64

Implementors§

§

impl Clock for ManualClock

§

impl Clock for SystemClock

Available on crate feature system only.