Skip to main content

rusty_time_core/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2//! rusty_time-core — portable NTP protocol and clock-discipline algorithms.
3//!
4//! This crate knows bytes, timestamps, and estimates. It performs no I/O, reads no
5//! OS clock, and holds no product types: a developer who has never heard of the rest
6//! of the workspace can drive it. All platform work lives behind the seams in
7//! `rusty_time-clock`; all wire transport lives in the deliverables.
8//!
9//! Sign convention used everywhere: an offset is **the number of seconds to ADD to
10//! the local clock** to match the source (RFC 5905 θ). Positive offset = local is
11//! behind.
12//!
13//! # The `no_std` leaf
14//!
15//! [`ntp`] compiles on every target with no `std` and no `alloc`: the NTPv4 packet
16//! codec ([`NtpPacket`], [`NtpTimestamp`], [`NtpShort`]), RFC 7822 extension-field
17//! iteration, and the RFC 5905 §8 offset/delay arithmetic. It reads no clock, opens
18//! no socket and owns no buffer, so an SNTP client on a Cortex-M4F or RV32 part can
19//! build a request, parse the response and compute an offset with nothing else.
20//!
21//! Everything above the wire — the regression sample filter, the discipline loop,
22//! falseticker selection, the server's client table, the config parser and the
23//! reference and virtual clocks — needs `Vec`/`String` and stays behind the
24//! default-on `std` feature. Take the leaf alone with:
25//!
26//! ```toml
27//! rusty_time-core = { version = "0.1", default-features = false }
28//! ```
29
30pub mod ntp;
31
32#[cfg(feature = "std")]
33pub mod client;
34#[cfg(feature = "std")]
35pub mod config;
36#[cfg(feature = "std")]
37pub mod discipline;
38#[cfg(feature = "std")]
39pub mod filter;
40#[cfg(feature = "std")]
41pub mod refclock;
42#[cfg(feature = "std")]
43pub mod select;
44#[cfg(feature = "std")]
45pub mod server;
46#[cfg(feature = "std")]
47pub mod vclock;
48
49pub use ntp::{LeapIndicator, Mode, NtpPacket, NtpShort, NtpTimestamp, ParseError};
50
51#[cfg(feature = "std")]
52pub use discipline::{ClockCommand, Discipline, DisciplineConfig, LeapMode, Plan};
53#[cfg(feature = "std")]
54pub use filter::{RegressEstimate, Sample, SampleRegister};
55#[cfg(feature = "std")]
56pub use select::{Selection, SourceEstimate};
57#[cfg(feature = "std")]
58pub use server::{
59    ClientHandle, ClientRecord, ClientTable, Disposition, RateLimitConfig, ResponseMode,
60    ServerStats,
61};
62#[cfg(feature = "std")]
63pub use vclock::VirtualClock;