pub struct GSet<T: Ord> { /* private fields */ }
Expand description
A GSet
is a grow-only set.
Implementations§
source§impl<T: Ord> GSet<T>
impl<T: Ord> GSet<T>
sourcepub fn insert(&mut self, element: T)
pub fn insert(&mut self, element: T)
Inserts an element into this GSet
.
Examples
use crdts::GSet;
let mut a = GSet::new();
a.insert(1);
assert!(a.contains(&1));
Trait Implementations§
source§impl<T: Ord> CmRDT for GSet<T>
impl<T: Ord> CmRDT for GSet<T>
§type Op = T
type Op = T
Op defines a mutation to the CRDT.
As long as Op’s from one actor are replayed in exactly the same order they
were generated by that actor, the CRDT will converge. In other words, we must
have a total ordering on each actors operations, while requiring only a partial
order over all ops.
E.g. Read more
§type Validation = Infallible
type Validation = Infallible
The validation error returned by
validate_op
.source§fn validate_op(&self, _op: &Self::Op) -> Result<(), Self::Validation>
fn validate_op(&self, _op: &Self::Op) -> Result<(), Self::Validation>
Some CRDT’s have stricter requirements on how they must be used.
To avoid violating these requirements, CRDT’s provide an interface
to optionally validate op’s before they are applied. Read more
source§impl<T: Ord> CvRDT for GSet<T>
impl<T: Ord> CvRDT for GSet<T>
source§fn merge(&mut self, other: Self)
fn merge(&mut self, other: Self)
Merges another GSet
into this one.
Examples
use crdts::{GSet, CvRDT, CmRDT};
let (mut a, mut b) = (GSet::new(), GSet::new());
a.insert(1);
b.insert(2);
a.merge(b);
assert!(a.contains(&1));
assert!(a.contains(&2));
§type Validation = Infallible
type Validation = Infallible
The validation error returned by
validate_merge
.source§fn validate_merge(&self, _other: &Self) -> Result<(), Self::Validation>
fn validate_merge(&self, _other: &Self) -> Result<(), Self::Validation>
Some CRDT’s have stricter requirements on how they must be used.
To avoid violating these requirements, CRDT’s provide an interface
to optionally validate merge compatibility before attempting to merge. Read more
source§impl<'de, T> Deserialize<'de> for GSet<T>where
T: Deserialize<'de> + Ord,
impl<'de, T> Deserialize<'de> for GSet<T>where T: Deserialize<'de> + Ord,
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<T: PartialEq + Ord> PartialEq<GSet<T>> for GSet<T>
impl<T: PartialEq + Ord> PartialEq<GSet<T>> for GSet<T>
impl<T: Eq + Ord> Eq for GSet<T>
impl<T: Ord> StructuralEq for GSet<T>
impl<T: Ord> StructuralPartialEq for GSet<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for GSet<T>where T: RefUnwindSafe,
impl<T> Send for GSet<T>where T: Send,
impl<T> Sync for GSet<T>where T: Sync,
impl<T> Unpin for GSet<T>
impl<T> UnwindSafe for GSet<T>where T: RefUnwindSafe,
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