Skip to main content

Clock

Trait Clock 

Source
pub trait Clock: Send + Sync {
    // Required method
    fn now(&self) -> Timestamp;

    // Provided method
    fn now_datetime(&self) -> OffsetDateTime { ... }
}
Expand description

A source of the current time.

Implementors are Send + Sync so a clock can be shared as Arc<dyn Clock> across tasks.

Required Methods§

Source

fn now(&self) -> Timestamp

The current instant.

Provided Methods§

Source

fn now_datetime(&self) -> OffsetDateTime

The current instant as a time::OffsetDateTime (always UTC).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§