pub struct PnCounter { /* private fields */ }Expand description
A state-based positive/negative counter with per-author components.
Implementations§
Source§impl PnCounter
impl PnCounter
Sourcepub fn increment(
&mut self,
author: AuthorId,
amount: u64,
) -> Result<(), CrdtError>
pub fn increment( &mut self, author: AuthorId, amount: u64, ) -> Result<(), CrdtError>
Adds to an author’s monotonic positive component.
Sourcepub fn decrement(
&mut self,
author: AuthorId,
amount: u64,
) -> Result<(), CrdtError>
pub fn decrement( &mut self, author: AuthorId, amount: u64, ) -> Result<(), CrdtError>
Adds to an author’s monotonic negative component.
Sourcepub fn value(&self) -> Result<i128, CrdtError>
pub fn value(&self) -> Result<i128, CrdtError>
Computes the signed counter value with overflow checking.
Sourcepub fn merge(&mut self, other: &PnCounter) -> Result<(), CrdtError>
pub fn merge(&mut self, other: &PnCounter) -> Result<(), CrdtError>
Deterministically combines another replica’s state.
Sourcepub fn canonicalize_for_commit(
&self,
author: AuthorId,
_sequence: u64,
_context: &VersionVector,
_next_operation: &mut u32,
) -> Result<PnCounter, CrdtError>
pub fn canonicalize_for_commit( &self, author: AuthorId, _sequence: u64, _context: &VersionVector, _next_operation: &mut u32, ) -> Result<PnCounter, CrdtError>
Attributes the visible signed value solely to the authenticated commit author.
Trait Implementations§
Source§impl FieldState for PnCounter
impl FieldState for PnCounter
Source§fn encode_state(&self) -> Result<Vec<u8>, RecordError>
fn encode_state(&self) -> Result<Vec<u8>, RecordError>
Encodes complete causal field state.
Source§fn decode_state(bytes: &[u8]) -> Result<PnCounter, RecordError>
fn decode_state(bytes: &[u8]) -> Result<PnCounter, RecordError>
Strictly decodes complete causal field state.
Source§fn visible_values(&self) -> Result<Vec<Vec<u8>>, RecordError>
fn visible_values(&self) -> Result<Vec<Vec<u8>>, RecordError>
Encodes each currently visible application value for filtering and indexes.
Source§fn merge_state(&mut self, other: &PnCounter) -> Result<(), RecordError>
fn merge_state(&mut self, other: &PnCounter) -> Result<(), RecordError>
Deterministically merges complete causal state from another replica.
Source§fn canonicalize_for_commit(
&self,
author: AuthorId,
sequence: u64,
context: &VersionVector,
next_operation: &mut u32,
) -> Result<PnCounter, RecordError>
fn canonicalize_for_commit( &self, author: AuthorId, sequence: u64, context: &VersionVector, next_operation: &mut u32, ) -> Result<PnCounter, RecordError>
Reissues all causal identities from one authenticated commit envelope.
Source§fn value_type_name() -> &'static str
fn value_type_name() -> &'static str
Stable Rust logical value type used in schema compatibility checks.
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 UnwindSafe for PnCounter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> RecordKey for T
impl<T> RecordKey for T
Source§fn encode_key(&self) -> Result<Vec<u8>, RecordError>
fn encode_key(&self) -> Result<Vec<u8>, RecordError>
Encodes this key into its unique durable representation.
Source§fn decode_key(bytes: &[u8]) -> Result<T, RecordError>
fn decode_key(bytes: &[u8]) -> Result<T, RecordError>
Strictly decodes a key from its unique durable representation.