pub struct Counters { /* private fields */ }
Expand description
Helper to count events for debugging purposes.
Counters
uses internal mutability to allow updating events without
requiring unique ownership or mutable countexts.
Implementations§
Source§impl Counters
impl Counters
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
Sourcepub fn set(&self, key: &'static str, value: u64)
pub fn set(&self, key: &'static str, value: u64)
Set the value of the counter for a given event key.
Sourcepub fn reset_event(&self, key: &'static str)
pub fn reset_event(&self, key: &'static str)
Reset the counter for the provided event key to zero.
Sourcepub fn reset_events<F: Filter>(&self, filter: F)
pub fn reset_events<F: Filter>(&self, filter: F)
Reset some of the counters to zero.
Sourcepub fn get(&self, key: &'static str) -> u64
pub fn get(&self, key: &'static str) -> u64
Get the value of the counter or zero if it does not exist.
Sourcepub fn accumulate<F: Filter>(&self, filter: F) -> u64
pub fn accumulate<F: Filter>(&self, filter: F) -> u64
Return the sum of all counters with keys containing the provided filter.
Sourcepub fn print<F: Filter>(&self, filter: F, to: &mut dyn Write) -> Result<()>
pub fn print<F: Filter>(&self, filter: F, to: &mut dyn Write) -> Result<()>
Print the counters to an io stream.
Sourcepub fn print_to_stdout<F: Filter>(&self, filter: F)
pub fn print_to_stdout<F: Filter>(&self, filter: F)
Print the counters to stdout.
Trait Implementations§
impl Eq for Counters
Auto Trait Implementations§
impl !Freeze for Counters
impl !RefUnwindSafe for Counters
impl Send for Counters
impl !Sync for Counters
impl Unpin for Counters
impl UnwindSafe for Counters
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