pub struct HlcTimestamp {
pub wall_time_ms: i64,
pub counter: u32,
pub node_id: u32,
}Expand description
A Hybrid Logical Clock timestamp.
Ordering: (wall_time, counter, node_id) — fully deterministic. Two HLC timestamps from different nodes are never equal.
Fields§
§wall_time_ms: i64Wall clock component (milliseconds since Unix epoch)
counter: u32Logical counter — incremented when wall clock hasn’t advanced
node_id: u32Node that generated this timestamp (0 for centralized mode)
Implementations§
Source§impl HlcTimestamp
impl HlcTimestamp
Sourcepub fn new(wall_time_ms: i64, counter: u32, node_id: u32) -> Self
pub fn new(wall_time_ms: i64, counter: u32, node_id: u32) -> Self
Create a timestamp from components.
Sourcepub fn to_datetime(&self) -> DateTime<Utc>
pub fn to_datetime(&self) -> DateTime<Utc>
Convert to a chrono DateTime (loses counter and node_id precision).
Sourcepub fn from_datetime(dt: DateTime<Utc>) -> Self
pub fn from_datetime(dt: DateTime<Utc>) -> Self
Create from a chrono DateTime (sets counter=0, node_id=0).
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<'de> Deserialize<'de> for HlcTimestamp
impl<'de> Deserialize<'de> for HlcTimestamp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for HlcTimestamp
impl Display 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
Source§impl Serialize for HlcTimestamp
impl Serialize 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.