pub trait Clock:
Send
+ Sync
+ Debug {
// Required methods
fn now_millis(&self) -> u64;
fn now_rfc3339(&self) -> String;
// Provided method
fn now_secs(&self) -> i64 { ... }
}Expand description
A time provider for getting current timestamps.
This trait abstracts over time sources to enable:
- Controllable time in tests (fixed starting point, manual advance)
- Monotonic timestamps within a single clock instance
Required Methods§
Sourcefn now_millis(&self) -> u64
fn now_millis(&self) -> u64
Returns the current time as milliseconds since Unix epoch.
Sourcefn now_rfc3339(&self) -> String
fn now_rfc3339(&self) -> String
Returns the current time as an RFC3339-formatted string.
Provided Methods§
Implementors§
impl Clock for FixedClock
Available on crate features
testing only.