Skip to main content

tilo_process_services/
time.rs

1//! The toolkit's clock: `tilo-clock`, under the toolkit's module path.
2//!
3//! Every monotonic and wall-clock reading in `ui` goes through [`now`] and
4//! [`wall`], and every clock type is named through this module rather than
5//! `std::time`. A process that has no process clock of its own (or one that must
6//! be virtualised, such as a deterministic replay) then has exactly one boundary to
7//! provide, instead of a hundred scattered `Instant::now()` calls.
8//!
9//! On targets with a native clock the re-exports are `std::time`'s own types,
10//! so values cross freely into crates that name `std::time` directly.
11//!
12//! `crates/ui/ui-core/clippy.toml` rejects `Instant::now` and
13//! `SystemTime::now` everywhere else in the crate.
14
15pub use tilo_clock::time::{Duration, Instant, SystemTime, SystemTimeError, UNIX_EPOCH};
16pub use tilo_clock::{
17    from_std, is_synchronised, local_zone_name, now, pin_wall, to_std, try_unix_now,
18    try_unix_now_ms, try_unix_now_ns, unix_now, unix_now_i64, unix_now_ms, unix_now_ms_i64,
19    unix_now_ns, wall, wall_frozen,
20};
21
22/// A file-system timestamp, as `std::fs::Metadata::modified` reports it, in
23/// the toolkit's [`SystemTime`].
24pub use tilo_clock::from_std as from_file_time;
25
26/// Scoped clock readings used by production-path input and deadline tests.
27#[cfg(feature = "test-support")]
28pub use tilo_clock::testing;