pub enum Unit {
Show 17 variants
Count,
Percent,
Seconds,
Milliseconds,
Microseconds,
Nanoseconds,
Tebibytes,
Gibibytes,
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 gibibytes.
Gibibytes
Gibibytes.
One gibibyte 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
impl Unit
Sourcepub fn as_canonical_label(&self) -> &'static str
pub fn as_canonical_label(&self) -> &'static 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.
Sourcepub fn from_string(s: &str) -> Option<Unit>
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
.
Sourcepub fn is_time_based(&self) -> bool
pub fn is_time_based(&self) -> bool
Whether or not this unit relates to the measurement of time.
Sourcepub fn is_data_based(&self) -> bool
pub fn is_data_based(&self) -> bool
Whether or not this unit relates to the measurement of data.
Sourcepub fn is_data_rate_based(&self) -> bool
pub fn is_data_rate_based(&self) -> bool
Whether or not this unit relates to the measurement of data rates.