Crate bytesize[−][src]
ByteSize is an utility that easily makes bytes size representation and helps its arithmetic operations.
Example
ⓘ
extern crate bytesize; use bytesize::ByteSize; fn byte_arithmetic_operator() { let x = ByteSize::mb(1); let y = ByteSize::kb(100); let plus = x + y; print!("{} bytes", plus.as_u64()); let minus = ByteSize::tb(100) - ByteSize::gb(4); print!("{} bytes", minus.as_u64()); }
It also provides its human readable string as follows:
assert_eq!("482 GiB".to_string(), ByteSize::gb(518).to_string(true));
assert_eq!("518 GB".to_string(), ByteSize::gb(518).to_string(false));
Structs
| ByteSize | Byte size representation |
Constants
| B | byte size for 1 byte |
| GB | bytes size for 1 gigabyte |
| GIB | bytes size for 1 gibibyte |
| KB | bytes size for 1 kilobyte |
| KIB | bytes size for 1 kibibyte |
| MB | bytes size for 1 megabyte |
| MIB | bytes size for 1 mebibyte |
| PB | bytes size for 1 petabyte |
| PIB | bytes size for 1 pebibyte |
| TB | bytes size for 1 terabyte |
| TIB | bytes size for 1 tebibyte |
Functions
| gb | |
| gib | |
| kb | |
| kib | |
| mb | |
| mib | |
| pb | |
| pib | |
| tb | |
| tib | |
| to_string |