Struct StateVector
pub struct StateVector(/* private fields */);Expand description
State vector is a compact representation of all known blocks inserted and integrated into a given document. This descriptor can be serialized and used to determine a difference between seen and unseen inserts of two replicas of the same document, potentially existing in different processes.
Another popular name for the concept represented by state vector is Version Vector.
Implementations§
§impl StateVector
impl StateVector
pub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns a number of unique clients observed by a document, current state vector corresponds to.
pub fn new( map: HashMap<u64, u32, BuildHasherDefault<ClientHasher>>, ) -> StateVector
pub fn contains(&self, id: &ID) -> bool
pub fn contains(&self, id: &ID) -> bool
Checks if current state vector includes given block identifier. Blocks, which identifiers can be found in a state vectors don’t need to be encoded as part of an update, because they were already observed by their remote peer, current state vector refers to.
pub fn contains_client(&self, client_id: &u64) -> bool
pub fn get(&self, client_id: &u64) -> u32
pub fn get(&self, client_id: &u64) -> u32
Get the latest clock sequence number value for a given client_id as observed from
the perspective of a current state vector.
pub fn inc_by(&mut self, client: u64, delta: u32)
pub fn inc_by(&mut self, client: u64, delta: u32)
Updates a state vector observed clock sequence number for a given client by incrementing
it by a given delta.
pub fn set_min(&mut self, client: u64, clock: u32)
pub fn set_min(&mut self, client: u64, clock: u32)
Updates a state vector observed clock sequence number for a given client by setting it to
a minimum value between an already present one and the provided clock. In case if state
vector didn’t contain any value for that client, a clock value will be used.
pub fn set_max(&mut self, client: u64, clock: u32)
pub fn set_max(&mut self, client: u64, clock: u32)
Updates a state vector observed clock sequence number for a given client by setting it to
a maximum value between an already present one and the provided clock. In case if state
vector didn’t contain any value for that client, a clock value will be used.
pub fn iter(&self) -> Iter<'_, u64, u32>
pub fn iter(&self) -> Iter<'_, u64, u32>
Returns an iterator which enables to traverse over all clients and their known clock values described by a current state vector.
pub fn merge(&mut self, other: StateVector)
pub fn merge(&mut self, other: StateVector)
Merges another state vector into a current one. Since vector’s clock values can only be incremented, whenever a conflict between two states happen (both state vectors have different clock values for the same client entry), a highest of these to is considered to be the most up-to-date.
Trait Implementations§
§impl Clone for StateVector
impl Clone for StateVector
§fn clone(&self) -> StateVector
fn clone(&self) -> StateVector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for StateVector
impl Debug for StateVector
§impl Decode for StateVector
impl Decode for StateVector
§impl Default for StateVector
impl Default for StateVector
§fn default() -> StateVector
fn default() -> StateVector
§impl Encode for StateVector
impl Encode for StateVector
§impl FromIterator<(u64, u32)> for StateVector
impl FromIterator<(u64, u32)> for StateVector
§fn from_iter<T>(iter: T) -> StateVector
fn from_iter<T>(iter: T) -> StateVector
§impl PartialEq for StateVector
impl PartialEq for StateVector
§impl PartialOrd for StateVector
impl PartialOrd for StateVector
impl Eq for StateVector
impl StructuralPartialEq for StateVector
Auto Trait Implementations§
impl Freeze for StateVector
impl RefUnwindSafe for StateVector
impl Send for StateVector
impl Sync for StateVector
impl Unpin for StateVector
impl UnwindSafe for StateVector
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§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
key and return true if they are equal.§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
§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>
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>
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