pub struct HlcTimestamp { /* private fields */ }Expand description
Hybrid Logical Clock timestamp.
Layout (12 bytes):
wall_time:i64— nanoseconds since Unix epoch (true nanosecond precision)logical:i32— counter for events within the same nanosecond
Comparison: wall_time first, then logical (total order). Big-endian byte serialization preserves comparison order for non-negative values.
Range:
- wall_time: covers ~292 years from epoch (until year 2262)
- logical: up to 2,147,483,647 events per nanosecond
Implementations§
Source§impl HlcTimestamp
impl HlcTimestamp
pub const ZERO: Self
Sourcepub fn new(wall_time_ns: i64, logical: i32) -> Self
pub fn new(wall_time_ns: i64, logical: i32) -> Self
Create from wall-clock time in nanoseconds and logical counter.
Sourcepub fn to_bytes(&self) -> [u8; 12]
pub fn to_bytes(&self) -> [u8; 12]
Serialize to 12 bytes big-endian (preserves comparison order for non-negative values).
Sourcepub fn from_bytes(b: &[u8; 12]) -> Self
pub fn from_bytes(b: &[u8; 12]) -> Self
Reconstruct from 12 bytes big-endian.
Trait Implementations§
Source§impl Clone for HlcTimestamp
impl Clone for HlcTimestamp
Source§fn clone(&self) -> HlcTimestamp
fn clone(&self) -> HlcTimestamp
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HlcTimestamp
impl Debug for HlcTimestamp
Source§impl Display for HlcTimestamp
impl Display for HlcTimestamp
Source§impl Hash for HlcTimestamp
impl Hash for HlcTimestamp
Source§impl Ord for HlcTimestamp
impl Ord for HlcTimestamp
Source§impl PartialEq for HlcTimestamp
impl PartialEq for HlcTimestamp
Source§impl PartialOrd for HlcTimestamp
impl PartialOrd for HlcTimestamp
impl Copy for HlcTimestamp
impl Eq for HlcTimestamp
impl StructuralPartialEq for HlcTimestamp
Auto Trait Implementations§
impl Freeze for HlcTimestamp
impl RefUnwindSafe for HlcTimestamp
impl Send for HlcTimestamp
impl Sync for HlcTimestamp
impl Unpin for HlcTimestamp
impl UnsafeUnpin for HlcTimestamp
impl UnwindSafe for HlcTimestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more