pub struct Hlc(/* private fields */);Expand description
A hybrid logical clock value, 64 bits: 48 bits of milliseconds since 1 January 2020 UTC in the high bits and a 16-bit logical counter in the low bits.
Commit timestamps, snapshots and page timestamps are Hlc values. The order of the u64 is the order of the clock.
Implementations§
Source§impl Hlc
impl Hlc
Sourcepub const EPOCH_UNIX_MS: u64 = 1_577_836_800_000
pub const EPOCH_UNIX_MS: u64 = 1_577_836_800_000
The Unix time of the epoch, 2020-01-01 00:00:00 UTC, in milliseconds.
Sourcepub const MAX_PHYSICAL: u64
pub const MAX_PHYSICAL: u64
The largest physical part, 2^48 - 1 milliseconds, about 8,900 years.
Sourcepub const fn new(physical: u64, logical: u16) -> Option<Hlc>
pub const fn new(physical: u64, logical: u16) -> Option<Hlc>
Makes a value from its two parts. Returns None if physical does not fit in 48 bits.
Sourcepub const fn physical_from_unix_ms(unix_ms: u64) -> u64
pub const fn physical_from_unix_ms(unix_ms: u64) -> u64
Converts a Unix time in milliseconds to the physical part. Times before the epoch become 0.
Sourcepub fn tick(self, wall: u64) -> Hlc
pub fn tick(self, wall: u64) -> Hlc
The next local value after self, for a local event at wall time wall (milliseconds since the epoch).
This is the send rule of Kulkarni and others (2014). If the wall clock is ahead, the value takes it with logical 0. Otherwise the logical counter goes up by one, and when it overflows the physical part goes forward by one millisecond.