Skip to main content

Module clock

Module clock 

Source
Expand description

Clock sources for absolute and elapsed-mode timestamping.

Per plan.md AD-008 and HINT-003: the Clock trait is injectable so snapshot tests can pin time to a deterministic fixed instant. The three impls cover:

  • Wall — system local wall clock (default for absolute timestamps).
  • Monotonic — std::time::Instant-backed monotonic source for the -m flag; unaffected by NTP / manual clock adjustments.
  • Fixed — test-only, returns a constant DateTime<Utc> so byte-level snapshot tests are deterministic regardless of when they run.

Structs§

Fixed
Fixed clock for snapshot determinism. Always returns the same instant. Test-only — gated to cfg(test) callers and the dev-only test harness.
Monotonic
Monotonic clock anchored at construction time. Reports a DateTime<Utc> derived as program_start_wall + elapsed_since_start. The wall component is fixed at construction; only the elapsed component advances. Used by -m to make -i and -s elapsed measurements robust against clock adjustments.
Wall
System wall clock via chrono::Utc::now(). The default for absolute timestamps in Default mode. Reflects any NTP / manual adjustments.

Traits§

Clock
Abstract clock source. Implementors must produce a DateTime<Utc> on every call to now(). Implementors that track elapsed time (Monotonic, Fixed) maintain their own internal anchor and must not require external synchronisation.