[][src]Struct counters::Table

pub struct Table { /* fields omitted */ }

Helper to print counters as a table in csv format.

Example

use counters::*;
 
let counters = Counters::new();
let table = Table::new(&["foo", "bar", "meh"]);
 
for _ in 0..5 {
    counters.event("bar");
}
counters.event("foo");
 
// "baz" isn't in the table labels, it will be ignored.
counters.event("baz");
 
table.add_row(&counters);
 
// Start a second row...
counters.reset_all();
 
counters.event("foo");
 
table.add_row(&counters);

// This prints the following to stdout:
// foo,bar,meh
// 1,5,0
// 1,0,0
table.print_to_stdout();

Methods

impl Table[src]

pub fn new(label_slice: &[&'static str]) -> Self[src]

pub fn add_row(&self, row: &Counters) -> usize[src]

Add collected counters as a row, preserving only the counters that match this table's labels.

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

Print in csv format to an io stream.

pub fn print_to_stdout(&self)[src]

Print in csv format to stdout.

Trait Implementations

impl Clone for Table[src]

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

Performs copy-assignment from source. Read more

impl Debug for Table[src]

Auto Trait Implementations

impl Send for Table

impl !Sync for Table

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.