pub enum Unit {
Show 51 variants
Nanosecond,
Microsecond,
Millisecond,
Second,
Minute,
Hour,
Day,
Week,
Month,
Quarter,
Year,
Bit,
Kb,
Mb,
Gb,
Tb,
Pb,
Eb,
Kib,
Mib,
Gib,
Tib,
Pib,
Eib,
Byte,
KB,
MB,
GB,
TB,
PB,
EB,
KiB,
MiB,
GiB,
TiB,
PiB,
EiB,
Request,
Query,
Percent,
USD,
EUR,
GBP,
JPY,
CNY,
CAD,
AUD,
CHF,
INR,
KRW,
RateUnit(Box<Unit>, Box<Unit>),
}Variants§
Nanosecond
Microsecond
Millisecond
Second
Minute
Hour
Day
Week
Month
Quarter
Year
Bit
Kb
Mb
Gb
Tb
Pb
Eb
Kib
Mib
Gib
Tib
Pib
Eib
Byte
KB
MB
GB
TB
PB
EB
KiB
MiB
GiB
TiB
PiB
EiB
Request
Query
Percent
USD
EUR
GBP
JPY
CNY
CAD
AUD
CHF
INR
KRW
RateUnit(Box<Unit>, Box<Unit>)
Implementations§
Source§impl Unit
impl Unit
Sourcepub fn to_base_value(&self, value: f64) -> f64
pub fn to_base_value(&self, value: f64) -> f64
Convert a value in this unit to the base unit for its type
Sourcepub fn from_base_value(self, base_value: f64) -> f64
pub fn from_base_value(self, base_value: f64) -> f64
Convert a base value to this unit
Sourcepub fn display_name(&self) -> Cow<'static, str>
pub fn display_name(&self) -> Cow<'static, str>
Get the display name for this unit
Sourcepub fn to_rate_unit(&self) -> Result<Unit, UnitConversionError>
pub fn to_rate_unit(&self) -> Result<Unit, UnitConversionError>
Convert a data unit to its corresponding rate unit (per second)
Sourcepub fn to_data_unit(&self) -> Result<Unit, UnitConversionError>
pub fn to_data_unit(&self) -> Result<Unit, UnitConversionError>
Convert a rate unit to its corresponding data unit
Sourcepub fn to_request_unit(&self) -> Result<Unit, UnitConversionError>
pub fn to_request_unit(&self) -> Result<Unit, UnitConversionError>
Convert a request rate unit to its corresponding count unit
Sourcepub fn is_compatible_for_addition(&self, other: &Unit) -> bool
pub fn is_compatible_for_addition(&self, other: &Unit) -> bool
Check if two units are compatible for addition/subtraction
Trait Implementations§
impl StructuralPartialEq for Unit
Auto Trait Implementations§
impl Freeze for Unit
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more