Module humanize_rs::bytes

source ·
Expand description

This module is used to parse a string to byte size, supports units of 2^10 like “KiB”, “MiB”, or units of 1000 like “KB”, “MB”

Example

use humanize_rs::bytes::{Bytes, Unit};

let gigabytes1 = Bytes::new(1, Unit::GiByte);
let gigabytes2 = "1 GiB".parse::<Bytes>();
assert_eq!(gigabytes1, gigabytes2);
assert_eq!(gigabytes2.unwrap().size(), 1 << 30);

Structs

Size calculated in Unit::Byte

Enums

Bytes units, like “KB”, “KiB”