pub struct Set<T: Eq + Hash + Clone> { /* private fields */ }Expand description
OR-Set CRDT. See the module docs for semantics.
Implementations§
Source§impl<T: Eq + Hash + Clone> Set<T>
impl<T: Eq + Hash + Clone> Set<T>
Sourcepub fn new_random() -> Self
pub fn new_random() -> Self
Create a new instance with a random ReplicaId from OS entropy.
See crate::new_replica_id.
Sourcepub fn replica_id(&self) -> ReplicaId
pub fn replica_id(&self) -> ReplicaId
This replica’s id.
Sourcepub fn add(&mut self, value: T) -> SetOp<T>
pub fn add(&mut self, value: T) -> SetOp<T>
Add value. If it’s already present, an additional tag is created;
removing it then requires a remove op that observes both tags
(which always happens when removes carry the tag list at remove-time).
Sourcepub fn remove(&mut self, value: &T) -> Option<SetOp<T>>
pub fn remove(&mut self, value: &T) -> Option<SetOp<T>>
Remove value. No-op (returns None) if the value is not present.
Sourcepub fn ops_since<'a>(
&'a self,
since: &'a VersionVector,
) -> impl Iterator<Item = &'a SetOp<T>> + 'a
pub fn ops_since<'a>( &'a self, since: &'a VersionVector, ) -> impl Iterator<Item = &'a SetOp<T>> + 'a
Iterate over ops not yet seen by since.
Sourcepub fn version(&self) -> &VersionVector
pub fn version(&self) -> &VersionVector
This replica’s current version vector.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Set<T>
Available on crate feature serde only.
impl<'de, T> Deserialize<'de> for Set<T>
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for Set<T>
impl<T> RefUnwindSafe for Set<T>where
T: RefUnwindSafe,
impl<T> Send for Set<T>where
T: Send,
impl<T> Sync for Set<T>where
T: Sync,
impl<T> Unpin for Set<T>where
T: Unpin,
impl<T> UnsafeUnpin for Set<T>
impl<T> UnwindSafe for Set<T>where
T: UnwindSafe,
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