Skip to main content

parse_size_constraint

Function parse_size_constraint 

Source
pub fn parse_size_constraint(s: &str) -> Result<(Option<u64>, Option<u64>)>
Expand description

Parse a human-readable byte size string like “5GB”, “10MB”, “500K”, or “6%10”.

Supports:

  • Binary: KiB, MiB, GiB, TiB, PiB
  • Decimal: KB, MB, GB, TB, PB
  • Plain bytes: B
  • Percentage: “6%10” means 6MB +/-10%

Returns (min_bytes, max_bytes). For exact values, min == max.

§Errors

Returns an error if the string cannot be parsed.