Enum metrics::Unit

source ·
pub enum Unit {
Show 17 variants Count, Percent, Seconds, Milliseconds, Microseconds, Nanoseconds, Tebibytes, Gigibytes, Mebibytes, Kibibytes, Bytes, TerabitsPerSecond, GigabitsPerSecond, MegabitsPerSecond, KilobitsPerSecond, BitsPerSecond, CountPerSecond,
}
Expand description

Units for a given metric.

While metrics do not necessarily need to be tied to a particular unit to be recorded, some downstream systems natively support defining units and so they can be specified during registration.

Variants§

§

Count

Count.

§

Percent

Percentage.

§

Seconds

Seconds.

One second is equal to 1000 milliseconds.

§

Milliseconds

Milliseconds.

One millisecond is equal to 1000 microseconds.

§

Microseconds

Microseconds.

One microsecond is equal to 1000 nanoseconds.

§

Nanoseconds

Nanoseconds.

§

Tebibytes

Tebibytes.

One tebibyte is equal to 1024 gigibytes.

§

Gigibytes

Gigibytes.

One gigibyte is equal to 1024 mebibytes.

§

Mebibytes

Mebibytes.

One mebibyte is equal to 1024 kibibytes.

§

Kibibytes

Kibibytes.

One kibibyte is equal to 1024 bytes.

§

Bytes

Bytes.

§

TerabitsPerSecond

Terabits per second.

One terabit is equal to 1000 gigabits.

§

GigabitsPerSecond

Gigabits per second.

One gigabit is equal to 1000 megabits.

§

MegabitsPerSecond

Megabits per second.

One megabit is equal to 1000 kilobits.

§

KilobitsPerSecond

Kilobits per second.

One kilobit is equal to 1000 bits.

§

BitsPerSecond

Bits per second.

§

CountPerSecond

Count per second.

Implementations§

source§

impl Unit

source

pub fn as_str(&self) -> &str

Gets the string form of this Unit.

source

pub fn as_canonical_label(&self) -> &str

Gets the canonical string label for the given unit.

For example, the canonical label for Seconds would be s, while for Nanoseconds, it would be ns.

Not all units have a meaningful display label and so some may be empty.

source

pub fn from_string(s: &str) -> Option<Unit>

Converts the string representation of a unit back into Unit if possible.

The value passed here should match the output of Unit::as_str.

source

pub fn is_time_based(&self) -> bool

Whether or not this unit relates to the measurement of time.

source

pub fn is_data_based(&self) -> bool

Whether or not this unit relates to the measurement of data.

source

pub fn is_data_rate_based(&self) -> bool

Whether or not this unit relates to the measurement of data rates.

Trait Implementations§

source§

impl Clone for Unit

source§

fn clone(&self) -> Unit

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Unit

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Unit

source§

fn eq(&self, other: &Unit) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Unit

source§

impl StructuralPartialEq for Unit

Auto Trait Implementations§

§

impl RefUnwindSafe for Unit

§

impl Send for Unit

§

impl Sync for Unit

§

impl Unpin for Unit

§

impl UnwindSafe for Unit

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.