Expand description
The clock seam, the foundation of deterministic time.
Production code must never read wall-clock time directly: a hidden
Instant::now() makes behavior depend on the machine and turns tests flaky.
Instead, every component that needs time takes a Clock. Production wires
SystemClock; tests wire ManualClock and advance it explicitly, so a
timeout, a TTL, or an affinity expiry is reproducible to the nanosecond.
This is enforced mechanically: clippy.toml bans SystemTime::now,
Instant::now, and friends everywhere except SystemClock, which is the
single sanctioned place that touches the real clock (docs/09, docs/12).
Structs§
- Instant
- A monotonic instant, in nanoseconds since an unspecified epoch.
- Manual
Clock - A test clock advanced explicitly. Starts at zero; never moves on its own.
- System
Clock - The production clock, backed by the operating system’s monotonic timer.
Traits§
- Clock
- A source of time. Inject this anywhere time is needed.