pub trait Clock {
// Required method
fn now(&self) -> SystemTime;
}Expand description
A trait that represents the capability to read the system time.
Using implementations of this trait instead of accessing the system clock directly allows mocking with a controlled clock for testing purposes.
Required Methods§
Sourcefn now(&self) -> SystemTime
fn now(&self) -> SystemTime
Returns the current system time, according to this clock.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Implementors§
impl Clock for FixedClock
Available on crate features
test-dependencies only.