pub trait Clock:
Send
+ Sync
+ 'static {
// Required method
fn now(&self) -> SystemTime;
// Provided methods
fn now_secs(&self) -> u64 { ... }
fn now_secs_i64(&self) -> i64 { ... }
}Expand description
Abstraction over the system clock.
Inject this into any component that needs time-based logic to enable deterministic testing without real-time delays.
Required Methods§
Sourcefn now(&self) -> SystemTime
fn now(&self) -> SystemTime
Return the current time.
Provided Methods§
Sourcefn now_secs(&self) -> u64
fn now_secs(&self) -> u64
Return the current Unix timestamp in whole seconds.
Equivalent to now().duration_since(UNIX_EPOCH).as_secs().
Sourcefn now_secs_i64(&self) -> i64
fn now_secs_i64(&self) -> i64
Return the current Unix timestamp as a signed 64-bit integer.
Safe until the year 292,277,026,596 when u64 overflows i64.