pub struct GCounter { /* private fields */ }Expand description
A grow-only counter that supports distributed increment operations.
Each replica has a unique ID and maintains its own count. The total value is the sum across all replicas. Merging takes the maximum count for each replica ID.
Implementations§
Source§impl GCounter
impl GCounter
Sourcepub fn with_replica_id(id: ReplicaId) -> Self
pub fn with_replica_id(id: ReplicaId) -> Self
Create a counter with a specific replica ID.
Sourcepub fn replica_id(&self) -> ReplicaId
pub fn replica_id(&self) -> ReplicaId
Get the replica ID for this counter.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GCounter
impl<'de> Deserialize<'de> for GCounter
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 PartialEq<i32> for GCounter
Compare a GCounter directly to an i32 value.
impl PartialEq<i32> for GCounter
Compare a GCounter directly to an i32 value.
Enables ergonomic conditionals with smaller integer types.
Source§impl PartialEq<u64> for GCounter
Compare a GCounter directly to a u64 value.
impl PartialEq<u64> for GCounter
Compare a GCounter directly to a u64 value.
Enables ergonomic conditionals like counter == 5 by comparing
the counter’s aggregated value to the integer.
impl StructuralPartialEq for GCounter
Auto Trait Implementations§
impl Freeze for GCounter
impl RefUnwindSafe for GCounter
impl Send for GCounter
impl Sync for GCounter
impl Unpin for GCounter
impl UnsafeUnpin for GCounter
impl UnwindSafe for GCounter
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