Enum byte_unit::ByteUnit [−][src]
pub enum ByteUnit {
Show 15 variants
B,
KB,
KiB,
MB,
MiB,
GB,
GiB,
TB,
TiB,
PB,
PiB,
EB,
EiB,
ZB,
ZiB,
}
Expand description
The unit of bytes.
Variants
1 B = 1 byte
1 KB = 1000 bytes (103)
1 KiB = 1024 bytes (210)
1 MB = 1000000 bytes (106)
1 MiB = 1048576 bytes (220)
1 GB = 1000000000 bytes (109)
1 GiB = 1073741824 bytes (230)
1 TB = 1000000000000 bytes (1012)
1 TiB = 1099511627776 bytes (240)
1 PB = 1000000000000000 bytes (1015)
1 PiB = 1125899906842624 bytes (250)
1 EB = 1000000000000000000 bytes (1018)
1 EiB = 1152921504606846976 bytes (260)
1 ZB = 1000000000000000000000 bytes (1021)
1 ZiB = 1180591620717411303424 bytes (270)
Implementations
Get an instance of ByteUnit
from a string slice.
extern crate byte_unit;
use byte_unit::ByteUnit;
assert_eq!(ByteUnit::B, ByteUnit::from_str("").unwrap());
assert_eq!(ByteUnit::B, ByteUnit::from_str("b").unwrap());
assert_eq!(ByteUnit::B, ByteUnit::from_str("B").unwrap());
assert_eq!(ByteUnit::KB, ByteUnit::from_str("k").unwrap());
assert_eq!(ByteUnit::KB, ByteUnit::from_str("K").unwrap());
assert_eq!(ByteUnit::KiB, ByteUnit::from_str("Kib").unwrap());
assert_eq!(ByteUnit::MB, ByteUnit::from_str("mb").unwrap());
assert_eq!(ByteUnit::MiB, ByteUnit::from_str("mib").unwrap());
assert_eq!(ByteUnit::GB, ByteUnit::from_str("GB").unwrap());
assert_eq!(ByteUnit::GiB, ByteUnit::from_str("GiB").unwrap());
assert_eq!(ByteUnit::TB, ByteUnit::from_str("TB").unwrap());
assert_eq!(ByteUnit::TiB, ByteUnit::from_str("TIB").unwrap());
assert_eq!(ByteUnit::PB, ByteUnit::from_str("PB").unwrap());
assert_eq!(ByteUnit::PiB, ByteUnit::from_str("PiB").unwrap());
Use string slice to represent this ByteUnit
.
extern crate byte_unit;
use byte_unit::ByteUnit;
assert_eq!("B", ByteUnit::B.as_str());
assert_eq!("KB", ByteUnit::KB.as_str());
assert_eq!("KiB", ByteUnit::KiB.as_str());
assert_eq!("MB", ByteUnit::MB.as_str());
assert_eq!("MiB", ByteUnit::MiB.as_str());
assert_eq!("GB", ByteUnit::GB.as_str());
assert_eq!("GiB", ByteUnit::GiB.as_str());
assert_eq!("TB", ByteUnit::TB.as_str());
assert_eq!("TiB", ByteUnit::TiB.as_str());
assert_eq!("PB", ByteUnit::PB.as_str());
assert_eq!("PiB", ByteUnit::PiB.as_str());
Get bytes represented by this ByteUnit
.
extern crate byte_unit;
use byte_unit::ByteUnit;
assert_eq!(1000000000000000000000, ByteUnit::ZB.get_unit_bytes());
assert_eq!(1152921504606846976, ByteUnit::EiB.get_unit_bytes());
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ByteUnit
impl UnwindSafe for ByteUnit
Blanket Implementations
Mutably borrows from an owned value. Read more