1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! Production `TimeSource` implementations backed by the operating system.
//!
//! `chronos` is the adapter layer for real, std-backed physical time. The
//! `kairos` core owns the [`TimeSource`] seam and
//! depends only on that trait; this module plugs concrete OS sources into it.
//! The whole module requires the `std` feature. The `no_std` core never enables
//! it, and the deterministic [`TickCounter`](crate::kairos::TickCounter) stays in
//! `kairos` precisely because it is `no_std`.
//!
//! # Choosing a source
//!
//! [`SystemTimeSource`] reads the wall clock
//! (nanoseconds since the Unix epoch). It is the right default for a
//! *distributed* clock: wall time is a shared frame of reference across
//! machines, so the `physical` component of a `Kairos` keeps its cross-node
//! meaning and [`Clock::after`](crate::kairos::Clock::after) can fold a remote
//! stamp in against a comparable scale. The wall clock can step backward: an
//! NTP correction, or an operator setting the clock. That is safe here. The
//! HLC never emits a decreasing stamp, because it takes the max of its last
//! physical and the reading. It records the regression as backward skew rather
//! than correcting it silently.
//!
//! [`MonotonicTimeSource`] reads a
//! per-process monotonic clock (nanoseconds since construction). It never steps
//! backward, but its zero point is process-local,
//! so its readings are *not* comparable across machines. Prefer it for
//! single-node ordering or for measuring elapsed time, not as the physical
//! component of a clock whose stamps cross a network.
extern crate std;
use crateTimeSource;
use ;
/// Saturating nanoseconds-to-`u64`. A `u64` of nanoseconds spans ~584 years;
/// past that both sources pin at the ceiling rather than wrapping, so a physical
/// reading never jumps backward on overflow.
/// Wall-clock [`TimeSource`]: nanoseconds since the Unix epoch.
///
/// The cross-node-comparable default for a distributed HLC. See the module docs
/// for why wall time, not a monotonic clock, is the right physical component when
/// stamps travel between machines.
;
/// Per-process monotonic [`TimeSource`]: nanoseconds since this source was
/// constructed.
///
/// Never steps backward, but its zero point is process-local, so readings are not
/// comparable across machines. See the module docs for when to prefer this over
/// [`SystemTimeSource`].