Skip to main content

Clock

Trait Clock 

Source
pub trait Clock:
    Send
    + Sync
    + 'static {
    // Required methods
    fn unix_secs(&self) -> i64;
    fn unix_millis(&self) -> i64;
    fn instant(&self) -> Instant;
    fn sleep(&self, d: Duration) -> Pin<Box<dyn Future<Output = ()> + Send>>;
}
Expand description

Source of time. Production code uses SystemClock; tests use ManualClock (feature test-util).

Required Methods§

Source

fn unix_secs(&self) -> i64

Unix seconds, 0 for a clock before 1970.

Source

fn unix_millis(&self) -> i64

Unix milliseconds, 0 for a clock before 1970.

Source

fn instant(&self) -> Instant

A monotonic instant.

Source

fn sleep(&self, d: Duration) -> Pin<Box<dyn Future<Output = ()> + Send>>

Completes after d on this clock.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§