pub fn format_binary_bandwidth(val: Bandwidth) -> FormattedBinaryBandwidthExpand description
Formats bandwidth into a human-readable string using the binary prefix system
Note: this format is NOT guaranteed to have same value when using parse_binary_bandwidth, the decimal part may varie du to the conversion between binary system and decimal system. Especially because rounding are tie to even when printing but tie to highest when reading
By default it will format the value with the largest possible unit in decimal form.
If you want to display integer values only, enable the display-integer feature.
ยงExamples
use bandwidth::Bandwidth;
use human_bandwidth::binary_system::format_binary_bandwidth;
// Enabling the `display-integer` feature will display integer values only
let val1 = Bandwidth::new(82772, 609728512);
assert_eq!(format_binary_bandwidth(val1).to_string(), "9TiB/s 420GiB/s");
let val2 = Bandwidth::new(0, 32 * 1024 * 1024);
assert_eq!(format_binary_bandwidth(val2).to_string(), "4MiB/s");
// Disabling the `display-integer` feature will display decimal values
let val1 = Bandwidth::from_bps((9 * 1024 + 512) * 1024 * 1024 * 1024 * 8);
assert_eq!(format_binary_bandwidth(val1).to_string(), "9.5TiB/s");
let val2 = Bandwidth::new(0, 32 * 1024 * 1024);
assert_eq!(format_binary_bandwidth(val2).to_string(), "4MiB/s");