Skip to main content

CalibratedClock

Struct CalibratedClock 

Source
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

Source

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).

Source

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.

Source

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).

Source

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).

Source

pub fn calibration(&self) -> Option<Calibration>

The active calibration, if the counter path is in use.

Trait Implementations§

Source§

impl Clock for CalibratedClock

Source§

fn now(&self) -> Timestamp

Current reading. t.mono never decreases across calls within a process, even if the underlying source regresses. REQ-CLK-001.
Source§

fn quality(&self) -> SyncQuality

Advisory sync quality of the underlying source (G2 — a hint, never a guarantee). REQ-CLK-004.
Source§

fn source(&self) -> ClockSource

Which underlying source reads are actually served from. REQ-CLK-003.
Source§

impl Clone for CalibratedClock

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CalibratedClock

Source§

impl Debug for CalibratedClock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.