Skip to main content

parse_size

Function parse_size 

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

Parse a GNU dd SIZE string with optional suffix and x multiplier.

Suffix conventions (matching GNU dd):

  • Single letter = binary (powers of 1024): k/K, M, G, T, P, E
  • xB suffix = decimal (powers of 1000): kB, KB, MB, GB, TB, PB, EB
  • xIB suffix = explicit binary: KiB, MiB, GiB, TiB, PiB, EiB
  • Special: c (1), w (2), b (512)

The x operator multiplies terms and chains recursively, so 1x2x4 = 1 * (2 * 4) = 8.