Skip to main content

zerodds_time_service/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3//! Crate `zerodds-time-service`. Safety classification: **STANDARD**.
4//!
5//! OMG Time Service 1.1 — Datatypes + Operations (Spec formal/2002-05-07).
6//! Pure-Rust no_std + alloc, `forbid(unsafe_code)`.
7//!
8//! ## Spec
9//!
10//! - **OMG Time Service 1.1** §1.3.2 (TimeBase: TimeT/InaccuracyT/TdfT/UtcT/IntervalT)
11//! - **OMG Time Service 1.1** §1.3.3 (TimeUnavailable Exception)
12//! - **OMG Time Service 1.1** §1.3.4 (UTO — Universal Time Object)
13//! - **OMG Time Service 1.1** §1.3.5 (TIO — Time Interval Object)
14//! - **OMG Time Service 1.1** §2.1 (TimeService Interface)
15//! - **OMG Time Service 1.1** §2.2 + §2.4 — TimerEventService: aus
16//!   ZeroDDS-Scope ausgenommen (verlangt CORBA-Event-Channel-ORB);
17//!   `corba-ccm` adressiert das im CCM-Container-PSM.
18//!
19//! ## Schichten-Position
20//!
21//! Layer 1 — Primitives. Standalone-Library; ZeroDDS verbraucht
22//! die Crate intern nicht (DDS-DCPS hat sein eigenes `Time_t` mit
23//! 8-Byte-Wire-Format gemaess DDS-DCPS §2.3.3, byte-distinkt zu OMG-
24//! Time-Service `UtcT` mit 16-Byte-Wire-Format und 1582-Epoch).
25//! Konsumenten sind End-User-Applikationen die OMG-Time-Service-1.1-
26//! Konformitaet brauchen (z.B. Tutorial `dds-warehouse/02-time-sync`).
27//!
28//! ## Public API (Stand 1.0.0-rc.1)
29//!
30//! **TimeBase** ([`time_base`]):
31//! - [`TimeT`] — 64-bit 100ns-Tick-Counter (Spec §1.3.2.1).
32//! - [`time_base::InaccuracyT`] / [`TdfT`] — 48-bit Inaccuracy + 16-bit
33//!   Time-Displacement-Factor.
34//! - [`UtcT`] — 16-Byte-Wire-Struct mit `to_wire`/`from_wire` Roundtrip.
35//! - [`IntervalT`] — Lower/Upper-bound mit Validation.
36//! - [`time_base::current_time`] — Wall-Clock in TimeT-Format
37//!   (no_std-Stub liefert `0`).
38//! - [`time_base::UTC_EPOCH_TO_UNIX_TICKS`] / [`time_base::TICKS_PER_SECOND`].
39//!
40//! **UTO** ([`uto`]):
41//! - [`Uto`] — Universal Time Object mit Operations (`absolute_time`,
42//!   `compare_time`, `time_to_interval`, `interval`).
43//! - [`ComparisonType::{IntervalC, MidC}`] — Vergleichs-Modus.
44//! - [`TimeComparison::{EqualTo, LessThan, GreaterThan, Indeterminate}`].
45//!
46//! **TIO** ([`tio`]):
47//! - [`Tio`] — Time Interval Object mit Operations (`time_interval`,
48//!   `overlaps`, `contains`, `spans`).
49//! - [`OverlapType`] — Overlap-Klassifizierung.
50//!
51//! **Service** ([`service`]):
52//! - [`TimeService`] — `universal_time` / `secure_universal_time` /
53//!   `new_universal_time` / `uto_from_utc` / `new_interval`.
54//! - [`TimeUnavailable`] — Exception-Type.
55//!
56//! ## Beispiel
57//!
58//! ```rust
59//! use zerodds_time_service::{TimeService, ComparisonType, TimeComparison};
60//!
61//! let service = TimeService::default();
62//! # if let Ok(now) = service.universal_time() {
63//! let later = service.universal_time().unwrap();
64//! assert_ne!(
65//!     now.compare_time(ComparisonType::MidC, later),
66//!     TimeComparison::GreaterThan
67//! );
68//! # }
69//! ```
70
71#![forbid(unsafe_code)]
72#![warn(missing_docs)]
73
74extern crate alloc;
75
76pub mod service;
77pub mod time_base;
78pub mod tio;
79pub mod uto;
80
81pub use service::{TimeService, TimeUnavailable};
82pub use time_base::{IntervalT, TdfT, TimeT, UtcT};
83pub use tio::{OverlapType, Tio};
84pub use uto::{ComparisonType, TimeComparison, Uto};