Skip to main content

parse_quantity_bytes

Function parse_quantity_bytes 

Source
pub fn parse_quantity_bytes(field: &str, value: &str) -> Result<u64>
Expand description

Parses a memory or storage quantity such as "16Gi", "500M" or "1024" into bytes.

Binary (Ki, Mi, Gi, Ti) and decimal (k, M, G, T) suffixes are accepted; a bare number is bytes. Fractions round to the nearest byte. Whitespace, signs and exponents are rejected, so a typo never turns into a surprising size.