axess-clock 0.2.0

Injectable Clock trait for deterministic simulation testing (DST). Foundational primitive used by axess and adjacent crates: production code depends on the `Clock` trait, tests inject `MockClock` to make time-dependent behaviour reproducible.
docs.rs failed to build axess-clock-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

axess-clock

Version Status License

crates.io · docs.rs · GitHub

Injectable Clock trait for deterministic simulation testing (DST). Foundational primitive used by Axess and adjacent crates.

Production code depends on the Clock trait. Tests inject MockClock to make time-dependent behaviour reproducible; TTL expiry, lockout windows, OTP step counters, refresh-token rotation, audit timestamps.

Usage

use axess_clock::{Clock, MockClock, SystemClock};
use std::sync::Arc;
use std::time::Duration;

// Production:
let clock: Arc<dyn Clock> = Arc::new(SystemClock);

// Tests:
let mock = MockClock::default();
let clock: Arc<dyn Clock> = Arc::new(mock.clone());
mock.advance(Duration::from_secs(60));   // wall clock jumps forward

Clock::now() returns chrono::DateTime<chrono::Utc>. Clock::monotonic_now() returns a std::time::Instant-equivalent backed by the same logical timeline so monotonic-only callers stay DST-pinned too.

Licence

Dual-licensed under MIT and Apache-2.0.