[−][src]Struct metrix::instruments::Counter
A simple ever increasing counter
Reacts to the following Observation
s:
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]
fn put_snapshot(&self, into: &mut Snapshot, descriptive: bool)
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,