pub struct Counter { /* private fields */ }Expand description
PN-Counter CRDT (signed). See the module docs for semantics.
Implementations§
Source§impl Counter
impl Counter
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 positive_total(&self) -> u128
pub fn positive_total(&self) -> u128
Sum of all positive contributions across all replicas.
Sourcepub fn negative_total(&self) -> u128
pub fn negative_total(&self) -> u128
Sum of all negative contributions across all replicas.
Sourcepub fn add(&mut self, delta: i64) -> CounterOp
pub fn add(&mut self, delta: i64) -> CounterOp
Apply a signed delta to this replica. Returns the generated op.
Sourcepub fn ops_since<'a>(
&'a self,
since: &'a VersionVector,
) -> impl Iterator<Item = &'a CounterOp> + 'a
pub fn ops_since<'a>( &'a self, since: &'a VersionVector, ) -> impl Iterator<Item = &'a CounterOp> + '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> Deserialize<'de> for Counter
impl<'de> Deserialize<'de> for Counter
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
Auto Trait Implementations§
impl Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnsafeUnpin for Counter
impl UnwindSafe for Counter
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