pub struct PnCounter { /* private fields */ }Expand description
An increment/decrement counter: a pair of G-Counters (increments P,
decrements N), join = componentwise.
Model: Crdt.PNCounter ι = (ι → ℕ) × (ι → ℕ) with the Prod lattice.
Deltas bump one side, one coordinate (SafeMesh.deltaBumpP /
deltaBumpN); each side accumulates exactly as a delta G-Counter
(SafeMesh.deltaPNCounter_correct_P / _N), and equal state gives an
equal read (SafeMesh.deltaPNCounter_value_matches).
Implementations§
Source§impl PnCounter
impl PnCounter
Sourcepub fn apply_inc(&mut self, replica: usize, tally: u64)
pub fn apply_inc(&mut self, replica: usize, tally: u64)
Apply SafeMesh.deltaBumpP replica tally — increment side, one
coordinate on the wire, ⊥ on the other side.
Out-of-range indices are ignored; use Self::try_apply_inc for an error.
Sourcepub fn try_apply_inc(
&mut self,
replica: usize,
tally: u64,
) -> Result<(), CoordinateError>
pub fn try_apply_inc( &mut self, replica: usize, tally: u64, ) -> Result<(), CoordinateError>
Apply an increment-side delta with a checked replica coordinate.
Returns CoordinateError::ReplicaOutOfRange before any mutation if the
index is invalid. Both sides remain unchanged on error. Valid input has
the same effect as Self::apply_inc.
Sourcepub fn apply_dec(&mut self, replica: usize, tally: u64)
pub fn apply_dec(&mut self, replica: usize, tally: u64)
Apply SafeMesh.deltaBumpN replica tally — decrement side.
Out-of-range indices are ignored; use Self::try_apply_dec for an error.
Sourcepub fn try_apply_dec(
&mut self,
replica: usize,
tally: u64,
) -> Result<(), CoordinateError>
pub fn try_apply_dec( &mut self, replica: usize, tally: u64, ) -> Result<(), CoordinateError>
Apply a decrement-side delta with a checked replica coordinate.
Returns CoordinateError::ReplicaOutOfRange before any mutation if the
index is invalid. Both sides remain unchanged on error. Valid input has
the same effect as Self::apply_dec.
Sourcepub fn try_merge(&mut self, other: &PnCounter) -> Result<(), MergeError>
pub fn try_merge(&mut self, other: &PnCounter) -> Result<(), MergeError>
Checked full-state merge: componentwise checked G-Counter merge,
erroring on a replica-count mismatch on either side instead of silently
truncating (WS1). Both sides are length-checked before any mutation, so
the operation is all-or-nothing: on error self is left unchanged.
Sourcepub fn merge(&mut self, other: &PnCounter)
pub fn merge(&mut self, other: &PnCounter)
Full-state merge: componentwise G-Counter merge —
Crdt.pncounter_merge_apply.
Infallible variant for the proven equal-length invariant; panics on a
replica-count mismatch. Use PnCounter::try_merge for untrusted input.
Trait Implementations§
Source§impl Crdt for PnCounter
impl Crdt for PnCounter
type Delta = PnCounterDelta
Source§fn replica_count(&self) -> Option<usize>
fn replica_count(&self) -> Option<usize>
None for CRDTs without a fixed arity.fn apply_delta(&mut self, delta: Self::Delta)
impl Eq for PnCounter
impl StructuralPartialEq for PnCounter
Auto Trait Implementations§
impl Freeze for PnCounter
impl RefUnwindSafe for PnCounter
impl Send for PnCounter
impl Sync for PnCounter
impl Unpin for PnCounter
impl UnsafeUnpin for PnCounter
impl UnwindSafe for PnCounter
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
Source§fn type_id(&self) -> TypeId
fn type_id(&self) -> TypeId
TypeId of self. Read moreSource§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
Source§fn borrow(&self) -> &T
fn borrow(&self) -> &T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)self to dest. Read moreSource§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§fn into(self) -> U
fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.