Crate readable_byte

Source
Expand description

readable_byte is an implmentation of human-readable bytesize

§Example

extern crate readable_byte;

use readable_byte::readable_byte;

fn byte_arithmetic_operator() {
  let x = readable_byte::mb(1);
  let y = readable_byte::kb(100);

  let plus = x + y;
  print!("{} bytes", plus.as_u64());

}

It also provides its human readable string as follows:

use readable_byte::to_string_u64;
 assert_eq!("448.9 GiB".to_string(), to_string_u64(readable_byte::gb(482_u64),true));
 assert_eq!("518.0 GB".to_string(), to_string_u64(readable_byte::gb(518_u64),false));

Structs§

readable_byte
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_u64