pub struct Counter { /* private fields */ }
Expand description
The main counter object that maps individual keys to count values.
Implementations§
source§impl Counter
impl Counter
A collection of counters that can store and modify values for a set of keys.
sourcepub fn add_one(&mut self, id: &str) -> i64
pub fn add_one(&mut self, id: &str) -> i64
Increment the counter value by one for the key given by id. Returns the value of the counter after it was incremented.
sourcepub fn sub_one(&mut self, id: &str) -> i64
pub fn sub_one(&mut self, id: &str) -> i64
Decrement the counter value by one for the key given by id. Returns the value of the counter after it was decremented.
sourcepub fn add_value(&mut self, id: &str, value: i64) -> i64
pub fn add_value(&mut self, id: &str, value: i64) -> i64
Increment the counter value by the given value for the key given by id. Returns the value of the counter after it was incremented.
sourcepub fn sub_value(&mut self, id: &str, value: i64) -> i64
pub fn sub_value(&mut self, id: &str, value: i64) -> i64
Decrement the counter value by the given value for the key given by id. Returns the value of the counter after it was decremented.
sourcepub fn set_value(&mut self, id: &str, value: i64) -> i64
pub fn set_value(&mut self, id: &str, value: i64) -> i64
Sets the counter value to the given value for the key given by id. Returns the value of the counter after it was set.
sourcepub fn get_value(&self, id: &str) -> i64
pub fn get_value(&self, id: &str) -> i64
Returns the counter value for the key given by id, or 0 if no operations have been performed on the key.
sourcepub fn add_counter(&mut self, other: &Counter)
pub fn add_counter(&mut self, other: &Counter)
Add all values for all keys in other
to this counter.
sourcepub fn sub_counter(&mut self, other: &Counter)
pub fn sub_counter(&mut self, other: &Counter)
Subtract all values for all keys in other
from this counter.
Trait Implementations§
impl Eq for Counter
impl StructuralPartialEq for Counter
Auto Trait Implementations§
impl Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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>
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>
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