Module units

Source
Expand description

Types for parsing/deserializing unit values.

let time = Time::from_str("10 min").unwrap();
assert_eq!(time, Time::new(10, TimePrefix::Min));

assert_eq!(
    time.convert(TimePrefix::Sec).unwrap(),
    Time::from_str("600 sec").unwrap()
);

Structs§

BitsPerSec
A throughput in bits-per-second.
Bytes
A number of bytes.
Time
An amount of time. Should only use the time prefix types (TimePrefix and TimePrefixUpper) with this type.

Enums§

SiPrefix
Common SI prefixes (including base-2 prefixes since they’re similar).
SiPrefixUpper
Common SI prefixes larger than the base unit (including base-2 prefixes since they’re similar).
TimePrefix
Time units, which we pretend are prefixes for implementation simplicity. These contain both the prefix (“n”, “u”, “m”) and the suffix (“sec”, “min”, “hr”) and should be used with the Time unit.
TimePrefixUpper
Time units larger than the base unit, which we pretend are prefixes for implementation simplicity. These really contain the unit suffix (“sec”, “min”, “hr”) and should be used with the Time unit.

Traits§

Prefix
The prefix of a unit value denoting magnitude. Common prefixes are SI prefixes (nano, micro, milli, etc).
Unit
A unit containing a value (ex: an integer), a prefix (ex: an enum), and allowed constant suffix strings.