Expand description
Clock abstraction for testable time-dependent logic.
Code that needs the current time should accept a &dyn Clock instead of
calling SystemTime::now() directly. Production callers pass
SystemClock; tests pass MockClock and advance it explicitly.
Both now_unix_secs() (wall clock) and now_monotonic() (monotonic) are
exposed because they have different uses:
- wall clock for timestamps stored in the database (session expiry,
createdAt) - monotonic for measuring elapsed time (rate-limiter windows, tick scheduling) — wall clock can jump backward via NTP
Structs§
- Mock
Clock - Test clock with manual advancement.
- System
Clock - Clock backed by
std::time— the production default.