time/lib.rs
1//! System-owned UTC and monotonic clocks. UTC is invalid until explicitly seeded.
2//!
3//! Native/browser runtimes bootstrap once through their typed `TimeDevice` source.
4//! Their host clock is trusted as the epoch supplier, not certified as accurate;
5//! subsequent host clock changes require explicit resynchronization.
6//! A target with no RTC can start the clock before any shell or network service:
7//!
8//! ```
9//! use time::{ClockSource, Manager, RealtimeSample, Timestamp};
10//! use core::time::Duration;
11//! let clock = Manager::unsynchronized();
12//! // Runtime policy validates the manual value (or obtains it from an RTC/network).
13//! clock.set_realtime(RealtimeSample {
14//! timestamp: Timestamp::from_nanos(1_700_000_000_000_000_000),
15//! source: ClockSource::Manual,
16//! resolution: Duration::from_secs(1),
17//! accuracy: None,
18//! }).unwrap();
19//! ```
20//!
21//! The API does not implement a synchronization protocol, timezone, persistence,
22//! authentication or automatic source fallback. Unsynchronized reads fail; current
23//! unsigned filesystem and WASI formats also reject pre-epoch/out-of-range UTC.
24
25#![no_std]
26
27extern crate alloc;
28
29embedded_i18n::i18n!("locales");
30
31mod error;
32mod manager;
33#[cfg(feature = "services")]
34pub mod manual;
35#[cfg(feature = "services")]
36pub mod real_time_clock;
37mod realtime;
38
39pub use error::*;
40pub use manager::*;
41pub use realtime::*;
42
43pub type Duration = core::time::Duration;