[][src]Struct metrix::instruments::Counter

pub struct Counter { /* fields omitted */ }

A simple ever increasing counter

Reacts to the following Observations:

  • Observation::Observed(Update::Observations)
  • Obervation::ObservedOne(Update::Observation)
  • Obervation::ObservedOneValue(Update::ObservationWithValue)

Example

use std::time::Instant;
use metrix::instruments::*;

let mut counter = Counter::new_with_defaults("example");
let update = Update::Observation(Instant::now());
counter.update(&update);

assert_eq!(1, counter.get());

Methods

impl Counter[src]

pub fn new_with_defaults<T: Into<String>>(name: T) -> Counter[src]

pub fn inc(&mut self)[src]

Increase the stored value by one.

pub fn inc_by(&mut self, n: u64)[src]

Increase the stored value by n

pub fn get(&self) -> u64[src]

Get the current value

pub fn name(&self) -> &str[src]

Gets the name of this Counter

pub fn set_name<T: Into<String>>(&mut self, name: T)[src]

Set the name if this Counter.

The name is a path segment within a Snapshot

pub fn set_title<T: Into<String>>(&mut self, title: T)[src]

Sets the title of this Counter.

A title can be part of a descriptive Snapshot

pub fn set_description<T: Into<String>>(&mut self, description: T)[src]

Sets the description of this Counter.

A description can be part of a descriptive Snapshot

Trait Implementations

impl Updates for Counter[src]

impl Instrument for Counter[src]

impl Descriptive for Counter[src]

impl PutsSnapshot for Counter[src]

Auto Trait Implementations

impl Send for Counter

impl Sync for Counter

impl Unpin for Counter

impl UnwindSafe for Counter

impl RefUnwindSafe for Counter

Blanket Implementations

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

impl<T> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,