Skip to main content

Clock

Trait Clock 

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

Clock trait for obtaining the current time

This trait abstracts time acquisition, making it mockable in tests. All time-dependent code should use this trait instead of calling Utc::now() directly.

Required Methods§

Source

fn now(&self) -> DateTime<Utc>

Returns the current time in UTC

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§