pub struct HlcTimestamp(/* private fields */);Expand description
Hybrid Logical Clock timestamp (64-bit packed).
Layout: [physical_ms: 44 bits][logical: 20 bits]
- 44 bits physical = ~557 years from epoch (sufficient until 2527)
- 20 bits logical = 1M events per millisecond per node
Implementations§
Source§impl HlcTimestamp
impl HlcTimestamp
Sourcepub const MAX_LOGICAL: u32
pub const MAX_LOGICAL: u32
Maximum value for the logical counter.
Sourcepub const fn new(physical_ms: u64, logical: u32) -> Self
pub const fn new(physical_ms: u64, logical: u32) -> Self
Create a new HLC timestamp from physical time (ms) and logical counter.
§Panics
Debug builds will panic if logical >= 2^20.
Sourcepub const fn physical_ms(&self) -> u64
pub const fn physical_ms(&self) -> u64
Extract the physical time component in milliseconds.
Sourcepub const fn to_nanos_approx(&self) -> u64
pub const fn to_nanos_approx(&self) -> u64
Convert to nanoseconds (approximate, for display/logging only).
Note: This loses precision since HLC uses milliseconds internally.
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 Default for HlcTimestamp
impl Default for HlcTimestamp
Source§fn default() -> HlcTimestamp
fn default() -> HlcTimestamp
Returns the “default value” for a type. Read more
Source§impl Display for HlcTimestamp
impl Display for HlcTimestamp
Source§impl FromBytes for HlcTimestamp
impl FromBytes for HlcTimestamp
Source§impl FromZeros for HlcTimestamp
impl FromZeros for HlcTimestamp
Source§impl Hash for HlcTimestamp
impl Hash for HlcTimestamp
Source§impl IntoBytes for HlcTimestamp
impl IntoBytes for HlcTimestamp
Source§impl Ord for HlcTimestamp
impl Ord for HlcTimestamp
Source§fn cmp(&self, other: &HlcTimestamp) -> Ordering
fn cmp(&self, other: &HlcTimestamp) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for HlcTimestamp
impl PartialEq for HlcTimestamp
Source§impl PartialOrd for HlcTimestamp
impl PartialOrd for HlcTimestamp
Source§impl TryFromBytes for HlcTimestampwhere
u64: TryFromBytes,
impl TryFromBytes for HlcTimestampwhere
u64: TryFromBytes,
Source§fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
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