[][src]Struct counters::Counters

pub struct Counters { /* fields omitted */ }

Helper to count events for debugging purposes.

Counters uses internal mutability to allow updating events without requiring unique ownership or mutable countexts.

Methods

impl Counters[src]

pub fn new() -> Self[src]

pub fn with_capacity(cap: usize) -> Self[src]

pub fn event(&self, key: &'static str)[src]

Increment the counter for the provided event key.

pub fn set(&self, key: &'static str, value: u64)[src]

Set the value of the counter for a given event key.

pub fn reset_event(&self, key: &'static str)[src]

Reset the counter for the provided event key to zero.

pub fn reset_events<F: Filter>(&self, filter: F)[src]

Reset some of the counters to zero.

pub fn reset_all(&self)[src]

Reset all counters to zero.

pub fn retain<F: Filter>(&self, filter: F)[src]

Keep some of the counters and throw away the rest.

pub fn get(&self, key: &'static str) -> u64[src]

Get the value of the counter or zero if it does not exist.

pub fn accumulate<F: Filter>(&self, filter: F) -> u64[src]

Return the sum of all counters with keys containing the provided filter.

pub fn print<F: Filter>(&self, filter: F, to: &mut dyn Write) -> Result<()>[src]

Print the counters to an io stream.

pub fn print_to_stdout<F: Filter>(&self, filter: F)[src]

Print the counters to stdout.

pub fn append(&self, other: &Counters)[src]

Moves all the elements of other into self, leaving other empty.

pub fn apply<F: Filter, Cb: FnMut(&'static str, u64) -> u64>(
    &self,
    filter: F,
    callback: Cb
)
[src]

Apply a function to all counters matching the provided filter.

Trait Implementations

impl PartialEq<Counters> for Counters[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl Clone for Counters[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for Counters[src]

impl Hash for Counters[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for Counters[src]

Auto Trait Implementations

impl Send for Counters

impl !Sync for Counters

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.