Expand description
Docker-style size strings for VM sizing flags (--memory, --disk-size).
Accepts <number><unit> with exact units b/k/m/g/t
(case-insensitive, optional b/ib suffix forms: 512m, 4g, 4GB,
4gib; decimals like 1.5g too). Anything else fails loudly —
including bare digits at this layer (see the parse_memory_mb /
parse_disk_gb fallbacks below for why those accept them).
All arithmetic is checked integer math (u128 intermediates): no float
precision holes near u64::MAX.
Constants§
- MIN_
DISK_ GB - Minimum install-disk size in GB: below this the image cannot be laid down.
- MIN_
MEMORY_ MB - Minimum guest RAM in MB: below this Windows 11 cannot boot to Setup. (The 4 GB Windows spec stays the recommended default, not the floor.)
Functions§
- parse_
disk_ gb - Parse
--disk-size: Docker syntax, or bare digits meaning GB. Enforces the disk floor. - parse_
memory_ mb - Parse
--memory: Docker syntax, or bare digits meaning MB (back-compat with the old integer flag). Enforces the RAM floor. Clapvalue_parsershape:Err(String)renders as a clean CLI error. - parse_
size_ bytes - Parse a Docker-style size string into bytes. Bare digits are rejected here (in real Docker syntax they mean bytes, a guaranteed footgun for VM sizing); the typed wrappers below give them safe meanings.