pub struct Timestamp {
pub clock: u64,
pub client_id: ClientID,
}Expand description
Timestamp for Last-Write-Wins conflict resolution
Contains both a logical clock value and a client ID for deterministic tie-breaking. This ensures that concurrent writes to the same field converge to the same value across all replicas.
Fields§
§clock: u64Logical clock value (higher = more recent)
client_id: ClientIDClient ID for tie-breaking when clocks are equal
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn compare_lww(&self, other: &Timestamp) -> Ordering
pub fn compare_lww(&self, other: &Timestamp) -> Ordering
Compare two timestamps for LWW conflict resolution
Returns:
- Ordering::Greater if self is more recent
- Ordering::Less if other is more recent
- Ordering::Equal if timestamps are identical (same clock and client)
Sourcepub fn is_newer_than(&self, other: &Timestamp) -> bool
pub fn is_newer_than(&self, other: &Timestamp) -> bool
Check if this timestamp is more recent than another (for LWW)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
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 Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
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