pub struct CalibratedClock { /* private fields */ }Expand description
Precision clock over a hardware counter, with transparent fallback.
Construct via CalibratedClock::new (falls back silently when the
counter is unusable — the requested precision stays observable through
Clock::source) or CalibratedClock::try_new (strict: construction
fails when the counter cannot be calibrated). REQ-CLK-003.
Implementations§
Source§impl CalibratedClock
impl CalibratedClock
Sourcepub fn new(reps: u32) -> Self
pub fn new(reps: u32) -> Self
Calibrate and construct; on any calibration failure construct the
reference-clock fallback instead (never fails). reps scales the
calibration workload (e.g. 1_000..=1_000_000).
Sourcepub fn try_new(reps: u32) -> Result<Self, CalError>
pub fn try_new(reps: u32) -> Result<Self, CalError>
Strict construction: Err when the hardware counter is unusable.
§Errors
Whatever calibrate reports (see its # Errors section) — the
fallback constructor CalibratedClock::new is the transparent
counterpart.
Sourcepub fn with_fallback() -> Self
pub fn with_fallback() -> Self
Construct the explicit reference-clock fallback — opting out of the counter path entirely (useful when a consumer wants the conservative source by policy, not by calibration outcome).
Sourcepub fn with_calibration(cal: Calibration) -> Self
pub fn with_calibration(cal: Calibration) -> Self
Construct directly from a pre-computed calibration (e.g. re-using a factor calibrated earlier in the process).
Sourcepub fn calibration(&self) -> Option<Calibration>
pub fn calibration(&self) -> Option<Calibration>
The active calibration, if the counter path is in use.
Trait Implementations§
Source§impl Clock for CalibratedClock
impl Clock for CalibratedClock
Source§fn now(&self) -> Timestamp
fn now(&self) -> Timestamp
t.mono never decreases across calls within a
process, even if the underlying source regresses. REQ-CLK-001.