Skip to main content

Module magnitude

Module magnitude 

Source
Expand description

Magnitude-suffix-aware numeric coercion for workload parameters.

A workload param declares its TYPE through the inferred type of its default value (max_size: 1000000 → u64). The declared default is the source of truth: when a CLI override supplies that param, the override is coerced to the default’s numeric type rather than being allowed to flip it to a string. The coercion understands magnitude suffixes, so max_size=10m means ten million:

  • decimal (powers of 1000): k M G B T P E (B = billion = G),
  • binary (powers of 1024): Ki Mi Gi Ti Pi Ei.

Suffixes are case-insensitive. A value that is already a plain number, or whose declared default is non-numeric, is returned unchanged — so a genuine string param (e.g. a glob like 100m) is never numified.

Functions§

coerce_param_override
Coerce a CLI override to the type inferred from a param’s declared default. When the default is numeric (u64 or f64) the override is parsed with parse_magnitude and re-emitted as a canonical numeric literal (integer for a u64 default, float for an f64 default). A non-numeric default, an already-plain-numeric override, or an unparseable override is returned unchanged (so the value, or any downstream type error, names exactly what the operator typed).
parse_magnitude
Parse a numeric string with an optional magnitude suffix into f64. Returns None if the string is not <number>[suffix].