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.