Struct crdts::lwwreg::LWWReg
[−]
[src]
pub struct LWWReg<T: PartialEq, A: Ord + Encodable + Decodable> { pub value: T, pub dot: A, }
LWWReg
is a simple CRDT that contains an arbitrary value
along with an Ord
that tracks causality. It is the responsibility
of the user to guarantee that the source of the causal element
is monotonic. Don't use timestamps unless you are comfortable
with divergence.
Fields
value |
|
dot |
|
Methods
impl<T: PartialEq, A: Ord + Encodable + Decodable> LWWReg<T, A>
[src]
fn merge(&mut self, other: LWWReg<T, A>)
Combines two LWWReg
instances according to the dot that
tracks causality. Panics if the dot is identical but the
contained element is different. If you would prefer divergence,
use merge_unsafe
below.
Panics
merge
will panic if passed a LWWReg
instance with an
identical dot but different element, indicating a breach
of monotonicity.
use crdts::LWWReg; let mut l1 = LWWReg { value: 1, dot: 2 }; let l2 = LWWReg { value: 3, dot: 2 }; // panics // l1.merge(l2);
unsafe fn merge_unsafe(&mut self, other: LWWReg<T, A>)
Combines two LWWReg
instances according to the dot that
tracks causality. This allows replicas to diverge if the dot
is identical but the element is not.
Trait Implementations
Derived Implementations
impl<T: Decodable + PartialEq, A: Decodable + Ord + Encodable + Decodable> Decodable for LWWReg<T, A>
[src]
impl<T: Encodable + PartialEq, A: Encodable + Ord + Encodable + Decodable> Encodable for LWWReg<T, A>
[src]
impl<T: Hash + PartialEq, A: Hash + Ord + Encodable + Decodable> Hash for LWWReg<T, A>
[src]
fn hash<__HTA: Hasher>(&self, __arg_0: &mut __HTA)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<T: Eq + PartialEq, A: Eq + Ord + Encodable + Decodable> Eq for LWWReg<T, A>
[src]
impl<T: PartialEq + PartialEq, A: PartialEq + Ord + Encodable + Decodable> PartialEq for LWWReg<T, A>
[src]
fn eq(&self, __arg_0: &LWWReg<T, A>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &LWWReg<T, A>) -> bool
This method tests for !=
.
impl<T: Clone + PartialEq, A: Clone + Ord + Encodable + Decodable> Clone for LWWReg<T, A>
[src]
fn clone(&self) -> LWWReg<T, A>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more