Skip to main content

VClock

Struct VClock 

Source
pub struct VClock { /* private fields */ }
Expand description

A vector clock for tracking causal relationships between events.

Each replica has a logical clock counter. The vector clock captures which events have been “seen” by tracking the maximum counter for each replica.

Implementations§

Source§

impl VClock

Source

pub fn new() -> Self

Create a new empty vector clock.

Source

pub fn increment(&mut self, replica: ReplicaId) -> u64

Increment the clock for a replica and return the new counter value.

Source

pub fn get(&self, replica: ReplicaId) -> u64

Get the current counter for a replica (0 if not seen).

Source

pub fn dominates(&self, other: &Self) -> bool

Check if self dominates other (self >= other for all replicas).

Returns true if for every replica in other, self has an equal or greater counter.

Source

pub fn concurrent(&self, other: &Self) -> bool

Check if self and other are concurrent (neither dominates the other).

Source

pub fn merge_vclock(&mut self, other: &Self)

Merge another vector clock into this one (pointwise max).

Source

pub fn replicas(&self) -> impl Iterator<Item = &ReplicaId>

Get all replicas in this clock.

Trait Implementations§

Source§

impl Clone for VClock

Source§

fn clone(&self) -> VClock

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VClock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VClock

Source§

fn default() -> VClock

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for VClock

Source§

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 Merge for VClock

Source§

fn merge(&mut self, other: &Self)

Merge another instance into self. Read more
Source§

impl PartialEq for VClock

Source§

fn eq(&self, other: &VClock) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for VClock

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for VClock

Source§

impl StructuralPartialEq for VClock

Auto Trait Implementations§

§

impl Freeze for VClock

§

impl RefUnwindSafe for VClock

§

impl Send for VClock

§

impl Sync for VClock

§

impl Unpin for VClock

§

impl UnwindSafe for VClock

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,