Struct HlcTimestamp
#[repr(C, align(8))]pub struct HlcTimestamp {
pub physical: u64,
pub logical: u64,
pub node_id: u64,
}Expand description
Hybrid Logical Clock timestamp.
Composed of:
- Physical time (wall clock in microseconds since epoch)
- Logical counter (for events at same physical time)
- Node ID (for tie-breaking across nodes)
This struct is 24 bytes and cache-line friendly.
Fields§
§physical: u64Physical time component (microseconds since UNIX epoch).
logical: u64Logical counter for events at the same physical time.
node_id: u64Node identifier for tie-breaking.
Implementations§
§impl HlcTimestamp
impl HlcTimestamp
pub const fn new(physical: u64, logical: u64, node_id: u64) -> HlcTimestamp
pub const fn new(physical: u64, logical: u64, node_id: u64) -> HlcTimestamp
Create a new HLC timestamp.
pub const fn zero() -> HlcTimestamp
pub const fn zero() -> HlcTimestamp
Create a zero timestamp (minimum value).
pub fn now(node_id: u64) -> HlcTimestamp
pub fn now(node_id: u64) -> HlcTimestamp
Create a timestamp from the current wall clock.
pub const fn pack(&self) -> u128
pub const fn pack(&self) -> u128
Pack timestamp into a single u128 for atomic comparison. Format: [physical:64][logical:48][node_id:16]
pub const fn unpack(packed: u128) -> HlcTimestamp
pub const fn unpack(packed: u128) -> HlcTimestamp
Unpack timestamp from u128.
Trait Implementations§
§impl AsBytes for HlcTimestampwhere
u64: AsBytes,
HasPadding<HlcTimestamp, ringkernel_core::::hlc::{impl#16}::{constant#0}>: ShouldBe<false>,
impl AsBytes for HlcTimestampwhere
u64: AsBytes,
HasPadding<HlcTimestamp, ringkernel_core::::hlc::{impl#16}::{constant#0}>: ShouldBe<false>,
§fn as_bytes_mut(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
fn as_bytes_mut(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
Gets the bytes of this value mutably. Read more
§fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>
fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>
§impl Clone for HlcTimestamp
impl Clone for HlcTimestamp
§fn clone(&self) -> HlcTimestamp
fn clone(&self) -> HlcTimestamp
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for HlcTimestamp
impl Debug for HlcTimestamp
§impl Default for HlcTimestamp
impl Default for HlcTimestamp
§fn default() -> HlcTimestamp
fn default() -> HlcTimestamp
Returns the “default value” for a type. Read more
§impl Display for HlcTimestamp
impl Display for HlcTimestamp
§impl FromBytes for HlcTimestampwhere
u64: FromBytes,
impl FromBytes for HlcTimestampwhere
u64: FromBytes,
§fn ref_from_prefix(bytes: &[u8]) -> Option<&Self>where
Self: Sized,
fn ref_from_prefix(bytes: &[u8]) -> Option<&Self>where
Self: Sized,
§fn ref_from_suffix(bytes: &[u8]) -> Option<&Self>where
Self: Sized,
fn ref_from_suffix(bytes: &[u8]) -> Option<&Self>where
Self: Sized,
§fn mut_from_prefix(bytes: &mut [u8]) -> Option<&mut Self>where
Self: Sized + AsBytes,
fn mut_from_prefix(bytes: &mut [u8]) -> Option<&mut Self>where
Self: Sized + AsBytes,
§fn mut_from_suffix(bytes: &mut [u8]) -> Option<&mut Self>where
Self: Sized + AsBytes,
fn mut_from_suffix(bytes: &mut [u8]) -> Option<&mut Self>where
Self: Sized + AsBytes,
§fn slice_from(bytes: &[u8]) -> Option<&[Self]>where
Self: Sized,
fn slice_from(bytes: &[u8]) -> Option<&[Self]>where
Self: Sized,
§fn slice_from_prefix(bytes: &[u8], count: usize) -> Option<(&[Self], &[u8])>where
Self: Sized,
fn slice_from_prefix(bytes: &[u8], count: usize) -> Option<(&[Self], &[u8])>where
Self: Sized,
Interprets the prefix of the given
bytes as a &[Self] with length
equal to count without copying. Read more§fn slice_from_suffix(bytes: &[u8], count: usize) -> Option<(&[u8], &[Self])>where
Self: Sized,
fn slice_from_suffix(bytes: &[u8], count: usize) -> Option<(&[u8], &[Self])>where
Self: Sized,
Interprets the suffix of the given
bytes as a &[Self] with length
equal to count without copying. Read more§fn mut_slice_from(bytes: &mut [u8]) -> Option<&mut [Self]>where
Self: Sized + AsBytes,
fn mut_slice_from(bytes: &mut [u8]) -> Option<&mut [Self]>where
Self: Sized + AsBytes,
§fn mut_slice_from_prefix(
bytes: &mut [u8],
count: usize,
) -> Option<(&mut [Self], &mut [u8])>where
Self: Sized + AsBytes,
fn mut_slice_from_prefix(
bytes: &mut [u8],
count: usize,
) -> Option<(&mut [Self], &mut [u8])>where
Self: Sized + AsBytes,
Interprets the prefix of the given
bytes as a &mut [Self] with length
equal to count without copying. Read more§fn mut_slice_from_suffix(
bytes: &mut [u8],
count: usize,
) -> Option<(&mut [u8], &mut [Self])>where
Self: Sized + AsBytes,
fn mut_slice_from_suffix(
bytes: &mut [u8],
count: usize,
) -> Option<(&mut [u8], &mut [Self])>where
Self: Sized + AsBytes,
Interprets the suffix of the given
bytes as a &mut [Self] with length
equal to count without copying. Read more§fn read_from_prefix(bytes: &[u8]) -> Option<Self>where
Self: Sized,
fn read_from_prefix(bytes: &[u8]) -> Option<Self>where
Self: Sized,
§impl FromZeroes for HlcTimestampwhere
u64: FromZeroes,
impl FromZeroes for HlcTimestampwhere
u64: FromZeroes,
§impl Hash for HlcTimestamp
impl Hash for HlcTimestamp
§impl Ord for HlcTimestamp
impl Ord for HlcTimestamp
§impl PartialEq for HlcTimestamp
impl PartialEq for HlcTimestamp
§impl PartialOrd for HlcTimestamp
impl PartialOrd for HlcTimestamp
impl Copy for HlcTimestamp
impl Eq for HlcTimestamp
impl Pod 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 UnwindSafe for HlcTimestamp
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CallHasher for T
impl<T> CallHasher for T
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.