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 Archive for HlcTimestampwhere
u64: Archive,
impl Archive for HlcTimestampwhere
u64: Archive,
§type Archived = ArchivedHlcTimestamp
type Archived = ArchivedHlcTimestamp
The archived representation of this type. Read more
§type Resolver = HlcTimestampResolver
type Resolver = HlcTimestampResolver
The resolver for this type. It must contain all the additional information from serializing
needed to make the archived type from the normal type.
§unsafe fn resolve(
&self,
pos: usize,
resolver: <HlcTimestamp as Archive>::Resolver,
out: *mut <HlcTimestamp as Archive>::Archived,
)
unsafe fn resolve( &self, pos: usize, resolver: <HlcTimestamp as Archive>::Resolver, out: *mut <HlcTimestamp as Archive>::Archived, )
Creates the archived version of this value at the given position and writes it to the given
output. Read more
§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 · Source§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<__D> Deserialize<HlcTimestamp, __D> for <HlcTimestamp as Archive>::Archived
impl<__D> Deserialize<HlcTimestamp, __D> for <HlcTimestamp as Archive>::Archived
§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<HlcTimestamp, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<HlcTimestamp, <__D as Fallible>::Error>
Deserializes using the given deserializer
§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<ArchivedHlcTimestamp> for HlcTimestamp
impl PartialEq<ArchivedHlcTimestamp> for HlcTimestamp
§impl PartialEq<HlcTimestamp> for ArchivedHlcTimestamp
impl PartialEq<HlcTimestamp> for ArchivedHlcTimestamp
§impl PartialEq for HlcTimestamp
impl PartialEq for HlcTimestamp
§impl PartialOrd for HlcTimestamp
impl PartialOrd for HlcTimestamp
§impl<__S> Serialize<__S> for HlcTimestamp
impl<__S> Serialize<__S> for HlcTimestamp
§fn serialize(
&self,
serializer: &mut __S,
) -> Result<<HlcTimestamp as Archive>::Resolver, <__S as Fallible>::Error>
fn serialize( &self, serializer: &mut __S, ) -> Result<<HlcTimestamp as Archive>::Resolver, <__S as Fallible>::Error>
Writes the dependencies for the object and returns a resolver that can create the archived
type.
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> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
The archived counterpart of this type. Unlike
Archive, it may be unsized. Read more§type MetadataResolver = ()
type MetadataResolver = ()
The resolver for the metadata of this type. Read more
§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata,
)
unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )
Creates the archived version of the metadata for this value at the given position and writes
it to the given output. Read more
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
§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.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§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.
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T, S> SerializeUnsized<S> for Twhere
T: Serialize<S>,
S: Serializer + ?Sized,
impl<T, S> SerializeUnsized<S> for Twhere
T: Serialize<S>,
S: Serializer + ?Sized,
§fn serialize_unsized(
&self,
serializer: &mut S,
) -> Result<usize, <S as Fallible>::Error>
fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>
Writes the object and returns the position of the archived type.
§fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>
fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>
Serializes the metadata for the given type.