pub struct Counter { /* private fields */ }Expand description
Fleet-wide keyed signed counters.
A missing key starts at zero for increment and decrement. Both methods
return the value after their atomic update. reset installs a missing key
or atomically returns an existing value to zero.
Implementations§
Source§impl Counter
impl Counter
pub fn new(fleet: Arc<Fleet>) -> Result<Counter, Error>
pub fn get(&self, key: &str) -> Result<Option<i64>, Error>
pub fn increment(&self, key: &str, by: i64) -> Result<i64, Error>
pub fn decrement(&self, key: &str, by: i64) -> Result<i64, Error>
Sourcepub fn reset(&self, key: &str) -> Result<(), Error>
pub fn reset(&self, key: &str) -> Result<(), Error>
Atomically set a key to zero, installing it when necessary.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Counter
impl !UnwindSafe for Counter
impl Freeze for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnsafeUnpin 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