Skip to main content

AnchorCell

Struct AnchorCell 

Source
pub struct AnchorCell { /* private fields */ }
Expand description

The (ticks, unix_nanos) correlation point a monotonic tick source is pinned to wall-clock time by — anchored once, re-anchorable later (an NTP/PTP discipline loop calling AnchorCell::set on a schedule).

This is the general, tick-domain, no_std shape for correlating a monotonic counter with the wall clock. Two clocks read independently (say Instant::now() and a wall-clock read) share no anchor, so one (ticks, unix_nanos) pair is stored here and every conversion is measured from it. ToUnixNanos is the conversion; AnchorConfig (module config, feature config) is the serializable mirror of the initial pair.

Seqlock-protected rather than set-once: a caller that never re-anchors pays nothing extra (one seqlock read costs the same as a plain load on the happy path); a caller running an NTP/PTP discipline loop gets a real re-anchor primitive instead of needing to rebuild the whole pipeline. What is deliberately NOT here yet: a frequency-drift/skew-slope correction term (the discipline loop’s rate correction, as opposed to its periodic offset correction). Re-anchoring alone already tracks a disciplined external time source at the loop’s correction cadence; adding a continuous skew term is the next increment, and this shape does not need to change to add it — a third seqlock-protected field (parts-per-billion drift) would join ticks/unix_nanos in the pair without touching ToUnixNanos’s call site.

Implementations§

Source§

impl AnchorCell

Source

pub fn new(ticks: Ticks, unix_nanos: UnixNanos) -> Self

Anchor ticks to unix_nanos now.

Source

pub fn set(&self, ticks: Ticks, unix_nanos: UnixNanos)

Re-anchor: pin a fresh (ticks, unix_nanos) correlation point. The discipline operation — call this from an NTP/PTP correction loop each time it resolves a fresh offset.

Source

pub fn get(&self) -> (Ticks, UnixNanos)

The current (ticks, unix_nanos) anchor pair, read as one consistent unit.

Trait Implementations§

Source§

impl Debug for AnchorCell

Source§

fn fmt(&self, formatter: &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> 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, 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.