pub struct VersionVector(/* private fields */);
Expand description
The PartialOrd
impl provides the “happened-before” relation like follows:
Some(Ordering::Equal)
-> the vectors are exactly equalSome(Ordering::Less)
-> the lhs vector happened-before the rhs vectorSome(Ordering::Greater)
-> the rhs vector happened-before the lhs vectorNone
-> the version vectors are concurrent
Implementations§
Source§impl VersionVector
impl VersionVector
pub fn first(writer_id: PublicKey) -> Self
Sourcepub fn insert(&mut self, writer_id: PublicKey, version: u64)
pub fn insert(&mut self, writer_id: PublicKey, version: u64)
Inserts an entry into this version vector. If the entry already exists, it’s overwritten only if the new version is higher than the existing version. This operation is idempotent.
Sourcepub fn get(&self, writer_id: &PublicKey) -> u64
pub fn get(&self, writer_id: &PublicKey) -> u64
Retrieves the version corresponding to the given replica id.
Sourcepub fn increment(&mut self, writer_id: PublicKey)
pub fn increment(&mut self, writer_id: PublicKey)
Increments the version corresponding to the given replica id.
Sourcepub fn incremented(self, writer_id: PublicKey) -> Self
pub fn incremented(self, writer_id: PublicKey) -> Self
Returns self
with the version corresponding to writer_id
incremented.
Sourcepub fn merge(&mut self, other: &Self)
pub fn merge(&mut self, other: &Self)
Merge two version vectors into one. The version of each entry in the resulting vector is the maximum of the corresponding entries of the input vectors.
This operation is commutative, associative and idempotent.
Sourcepub fn saturating_sub(&self, rhs: &Self) -> Self
pub fn saturating_sub(&self, rhs: &Self) -> Self
Saturating subtraction.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Add for &VersionVector
impl Add for &VersionVector
Source§impl<'a> AddAssign<&'a VersionVector> for VersionVector
impl<'a> AddAssign<&'a VersionVector> for VersionVector
Source§fn add_assign(&mut self, rhs: &'a VersionVector)
fn add_assign(&mut self, rhs: &'a VersionVector)
Performs the
+=
operation. Read moreSource§impl AddAssign for VersionVector
impl AddAssign for VersionVector
Source§fn add_assign(&mut self, rhs: VersionVector)
fn add_assign(&mut self, rhs: VersionVector)
Performs the
+=
operation. Read moreSource§impl Clone for VersionVector
impl Clone for VersionVector
Source§fn clone(&self) -> VersionVector
fn clone(&self) -> VersionVector
Returns a copy 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 VersionVector
impl Debug for VersionVector
Source§impl<'r> Decode<'r, Sqlite> for VersionVector
impl<'r> Decode<'r, Sqlite> for VersionVector
Source§impl Default for VersionVector
impl Default for VersionVector
Source§fn default() -> VersionVector
fn default() -> VersionVector
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for VersionVector
impl<'de> Deserialize<'de> for VersionVector
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<'q> Encode<'q, Sqlite> for VersionVector
impl<'q> Encode<'q, Sqlite> for VersionVector
Source§fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
§fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
Writes the value of
self
into buf
in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Source§impl FromIterator<(PublicKey, u64)> for VersionVector
impl FromIterator<(PublicKey, u64)> for VersionVector
Source§impl Hashable for VersionVector
impl Hashable for VersionVector
Source§impl PartialEq for VersionVector
impl PartialEq for VersionVector
Source§impl PartialOrd for VersionVector
impl PartialOrd for VersionVector
Source§impl Serialize for VersionVector
impl Serialize for VersionVector
Source§impl<'a> Sum<&'a VersionVector> for VersionVector
impl<'a> Sum<&'a VersionVector> for VersionVector
Source§fn sum<I>(iter: I) -> Selfwhere
I: Iterator<Item = &'a VersionVector>,
fn sum<I>(iter: I) -> Selfwhere
I: Iterator<Item = &'a VersionVector>,
Takes an iterator and generates
Self
from the elements by “summing up”
the items.Source§impl Type<Sqlite> for VersionVector
impl Type<Sqlite> for VersionVector
impl Eq for VersionVector
Auto Trait Implementations§
impl Freeze for VersionVector
impl RefUnwindSafe for VersionVector
impl Send for VersionVector
impl Sync for VersionVector
impl Unpin for VersionVector
impl UnwindSafe for VersionVector
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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.§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