Module binary_system

Module binary_system 

Source
Expand description

Module to allow the display of bandwidth in binary prefix system

§Conversion

Unlike the international system, the binary system uses powers of 2 instead of powers of 10. More over the base unit here is Byte (or octet) per second and not bit per second, for reminder 1 Byte = 8 bits.

Examples:

  • 1B/s is equal to 8bps
  • 1kiB/s is equal to 8.192kbps
  • 1MiBps is equal to 8.388_608kbps

§Example

use bandwidth::Bandwidth;
use human_bandwidth::binary_system::format_binary_bandwidth;

let val = Bandwidth::new(0, 32 * 1024 * 1024);
assert_eq!(format_binary_bandwidth(val).to_string(), "4MiB/s");

Modules§

serde
Serde support for humanized bandwidth in binary prefix format.

Structs§

FormattedBinaryBandwidth
A wrapper type that allows you to Display a Bandwidth in binary prefix system

Functions§

format_binary_bandwidth
Formats bandwidth into a human-readable string using the binary prefix system
parse_binary_bandwidth
Parse bandwidth object 1GiBps 12MiBps 5Bps or 1.012000005GiBps