Skip to main content

Module byte_size

Module byte_size 

Source
Expand description

Parse a human byte size (4MiB, 1048576, 2M) for CLI value_parsers. Binary units only: K/KiB/KB = 1024, M/MiB/MB = 1024², G/GiB/GB = 1024³.

Functions§

parse_byte_size
Parse a byte size: a bare integer (bytes) or an integer followed by a binary unit suffix (K/KiB/KB, M/MiB/MB, G/GiB/GB, all powers of 1024). Returns the size in bytes. The error is a String so it renders directly in clap’s value_parser diagnostics.