Skip to main content

Clock

Trait Clock 

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

A monotonic-ish source of “seconds since epoch” used by the agent for pending-queue timestamps. Implementations must be Debug + Send + Sync so the agent (which derives Debug and may move across threads) can hold an Arc<dyn Clock>.

Required Methods§

Source

fn now(&self) -> u64

Return the current time in seconds. The exact epoch is up to the implementation as long as it is consistent across calls — the agent only ever compares values from the same clock against each other (e.g. now.saturating_sub(inserted_at) >= ttl).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Clock for NoClock

Source§

impl Clock for SystemClock

Available on crate feature std only.