Skip to main content

Module clock

Module clock 

Source
Expand description

Wall-clock source, injected so consumers read “now” deterministically in tests.

Production wires SystemClock (real Utc::now()); tests construct a deterministic fake (FixedClock / ClosureClock) and pass it to the unit under test.

The hybrid logical clock retains this same clock and derives epoch milliseconds from it. Other consumers use the full DateTime<Utc> for created_at, updated_at, and expiry comparisons.

Structs§

ClosureClock
Delegates each read to a supplied test function.
FixedClock
Every now() returns the same instant.
Stopwatch
Elapsed real time, for measuring how long a piece of work took.
SystemClock
Production clock: real wall time.

Traits§

Clock
Wall-clock source. Returns a full DateTime<Utc>; callers derive .timestamp() / .to_rfc3339() as they need.

Functions§

clock_from_millis
A ClockRef reading epoch milliseconds from a test-supplied source, for the hybrid-logical-clock tests that think in milliseconds rather than DateTimes.

Type Aliases§

ClockRef
Shared handle to a clock. Held by Clone types (CovenHandle, CovenReadHandle) so they clone the handle, not the implementation.