pub trait Clock: Send + Sync {
// Required method
fn now_ms(&self) -> TimestampMs;
}Expand description
A source of wall-clock time. Injected into crate::Grit via
crate::Options; tests inject ManualClock for full determinism.
Contract: implementations should return non-negative values (times at or after the Unix epoch). grit clamps negative readings to 0 wherever they would feed an HLC — the sortable HLC encoding is only order-preserving for non-negative wall times.
§Example
use grit_core::{Clock, ManualClock};
let clock = ManualClock::new(1_000);
assert_eq!(clock.now_ms(), 1_000);
clock.advance_ms(5);
assert_eq!(clock.now_ms(), 1_005);Required Methods§
Sourcefn now_ms(&self) -> TimestampMs
fn now_ms(&self) -> TimestampMs
Current wall time in milliseconds since the Unix epoch.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".