bytesize-2.6.0 has been yanked.
ByteSize
ByteSize is a semantic wrapper for byte count representations.
Features:
- Pre-defined constants for various size units (e.g., B, KB, KiB, MB, MiB, ... EB, EiB).
ByteSizetype which presents size units convertible to different size units.- Arithmetic operations for
ByteSize. FromStrimpl forByteSize, allowing for parsing string size representations like "1.5KiB" and "521TiB".- Serde support for binary and human-readable deserializers like JSON.
Feature flags
std(default): Enables theallocfeature and standard library optimizations.alloc: Enables parsing and formatting.arbitrary: Implementsarbitrary::Arbitraryfor [ByteSize].serde: Enablesallocand implements serialization and deserialization for [ByteSize].
Disable the default features to use only the core data types, conversions, and constants.
Examples
Construction using SI or IEC helpers.
use ByteSize;
assert!;
Display as human-readable string.
use ByteSize;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Arithmetic operations are supported.
use ByteSize;
let plus = mb + kb;
println!;
let minus = tb - gb;
assert_eq!;