proxima-clock
Hardware-clock source polymorphism expressed as proxima-primitives pipes: tick sources, wall-clock anchoring, and a coarse shared-time cell. The crate defines no clock trait of its own.
Add it with cargo add proxima-clock.
Why there is no Clock trait
A monotonic tick source (a memory-mapped register read, rdtsc, mrs CNTVCT_EL0) takes nothing and produces a reading. That is the source form of the Pipe trait, In = (), Out = Ticks, so binding a new hardware backend is "implement Pipe for your type". The crate's lib docs work through the other shapes the same way:
- a sleeper is a
PipewithIn = Ticks, Out = ()whose future pends until the deadline (the sink form); this crate ships no reference sleeper, because a correct one needs an interrupt or a runtime's timer wheel; - converting ticks to wall-clock time is a
PipewithIn = Ticks, Out = UnixNanos, which isToUnixNanos, composed onto a source with.and_then; - arbitrating between redundant tick sources is
proxima_primitives::pipe::fan_in::FanIn.
What it provides
TicksandUnixNanos: value types so tick-domain and wall-clock-domain arithmetic cannot be mixed by accident.TickCell(coarse): a shared coarse-time cell a hardware-facing pipe can hold.AnchorCellandToUnixNanos(anchor): the seqlock-protected(ticks, unix_nanos)correlation point, re-anchorable by an NTP or PTP discipline loop, and the pipe that applies it.
What it composes
proxima-primitives (the Pipe trait). proxima-telemetry uses it for its std SystemClock bridge, and prime uses TickCell for its virtual-clock timer wheel.
Features and tiers
Default feature: std.
- Bare no_std, no alloc:
ticks,unix_nanos,coarseandanchorcontain noalloc::items. Per the lib docs,--no-default-featuresbuilds forthumbv7m-none-eabiand runs the crate's unit tests. std(default): turns offno_std; adds no API.config(opt-in, impliesstd): a config plus fluent-builder surface (bon,conflaguration,serde) forAnchorCell's initial(ticks, unix_nanos)pair. It sits at the std boundary becauseconflagurationis std-only.
License
MIT OR Apache-2.0.
Repository: https://github.com/brianbruggeman/proxima