Struct crdts::lwwreg::LWWReg [] [src]

pub struct LWWReg<T, A> where
    T: PartialEq + Serialize + DeserializeOwned,
    A: Ord + Serialize + DeserializeOwned
{ 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 is the opaque element contained within this CRDT

dot should be a monotonic value associated with this value

Methods

impl<T, A> LWWReg<T, A> where
    T: PartialEq + Serialize + DeserializeOwned,
    A: Ord + Serialize + DeserializeOwned
[src]

[src]

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);

[src]

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

impl<T: Debug, A: Debug> Debug for LWWReg<T, A> where
    T: PartialEq + Serialize + DeserializeOwned,
    A: Ord + Serialize + DeserializeOwned
[src]

[src]

Formats the value using the given formatter.

impl<T: Clone, A: Clone> Clone for LWWReg<T, A> where
    T: PartialEq + Serialize + DeserializeOwned,
    A: Ord + Serialize + DeserializeOwned
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: PartialEq, A: PartialEq> PartialEq for LWWReg<T, A> where
    T: PartialEq + Serialize + DeserializeOwned,
    A: Ord + Serialize + DeserializeOwned
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T: Eq, A: Eq> Eq for LWWReg<T, A> where
    T: PartialEq + Serialize + DeserializeOwned,
    A: Ord + Serialize + DeserializeOwned
[src]

impl<T: Hash, A: Hash> Hash for LWWReg<T, A> where
    T: PartialEq + Serialize + DeserializeOwned,
    A: Ord + Serialize + DeserializeOwned
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more