Skip to main content

Crate rusty_time_core

Crate rusty_time_core 

Source
Expand description

rusty_time-core — portable NTP protocol and clock-discipline algorithms.

This crate knows bytes, timestamps, and estimates. It performs no I/O, reads no OS clock, and holds no product types: a developer who has never heard of the rest of the workspace can drive it. All platform work lives behind the seams in rusty_time-clock; all wire transport lives in the deliverables.

Sign convention used everywhere: an offset is the number of seconds to ADD to the local clock to match the source (RFC 5905 θ). Positive offset = local is behind.

§The no_std leaf

ntp compiles on every target with no std and no alloc: the NTPv4 packet codec (NtpPacket, NtpTimestamp, NtpShort), RFC 7822 extension-field iteration, and the RFC 5905 §8 offset/delay arithmetic. It reads no clock, opens no socket and owns no buffer, so an SNTP client on a Cortex-M4F or RV32 part can build a request, parse the response and compute an offset with nothing else.

Everything above the wire — the regression sample filter, the discipline loop, falseticker selection, the server’s client table, the config parser and the reference and virtual clocks — needs Vec/String and stays behind the default-on std feature. Take the leaf alone with:

rusty_time-core = { version = "0.1", default-features = false }

Re-exports§

pub use ntp::LeapIndicator;
pub use ntp::Mode;
pub use ntp::NtpPacket;
pub use ntp::NtpShort;
pub use ntp::NtpTimestamp;
pub use ntp::ParseError;
pub use discipline::ClockCommand;
pub use discipline::Discipline;
pub use discipline::DisciplineConfig;
pub use discipline::LeapMode;
pub use discipline::Plan;
pub use filter::RegressEstimate;
pub use filter::Sample;
pub use filter::SampleRegister;
pub use select::Selection;
pub use select::SourceEstimate;
pub use server::ClientHandle;
pub use server::ClientRecord;
pub use server::ClientTable;
pub use server::Disposition;
pub use server::RateLimitConfig;
pub use server::ResponseMode;
pub use server::ServerStats;
pub use vclock::VirtualClock;

Modules§

client
The client-side synchronisation controller.
config
chrony.conf-compatible configuration (the documented subset).
discipline
The clock-discipline loop: turn estimates into clock commands.
filter
Per-source sample history and regression estimation.
ntp
NTPv4 packet codec (RFC 5905) with extension-field iteration (RFC 7822).
refclock
Reference-clock samples: what a GPS, a PPS edge or a PTP hardware clock hands us, and what must be true before any of it is believed.
select
Source selection: falseticker rejection by interval intersection (RFC 5905 §11.2.1) and weighted combining.
server
Server-side policy: client tracking, rate limiting, and interleaved mode.
vclock
The virtual clock: a disciplined view of time for hosts where the OS clock cannot be adjusted (wasm, unprivileged processes) — and the holdover model everywhere else.