Expand description
CLI-facing value construction for set/add: a bare VALUE/FIELD=VALUE is
always Value::String with zero coercion — no shape-guessing, no type
prefixes. An exact type is requested explicitly via ValueType (set’s
--value-type flag); guard_bare_overwrite is the heterogeneous-overwrite
guard that turns a bare VALUE silently rewriting what is already at the path
— a scalar of another type, or a whole container — into an argument error
instead.
Enums§
- Bare
Overwrite - What a bare VALUE would overwrite, and the
--value-typethat would keep it — seeguard_bare_overwrite. - Scalar
Kind - The four AFDATA scalar “kinds” the heterogeneous-overwrite guard
distinguishes.
NumbercoversInteger/Unsigned/Float/Value::Number— the guard cares whether VALUE would change a scalar from one of these kinds to a bare string, not which numeric representation was in play. - Value
Type - The exact type an explicit
--value-typerequests for asetVALUE.
Functions§
- coerce_
toward - Coerce a CLI string toward the type already present at
existing, for a consumer that knows the target type from the value it is replacing (a config setter reading typed leaves out of a serialized document). - coerce_
values_ toward - Coerce a CLI value slice toward the type at
existingviacoerce_toward: one value becomes a scalar, several become an array whose elements are each coerced toward the existing array’s element type. An empty slice is an error. - guard_
bare_ overwrite - The heterogeneous-overwrite guard, which closes the “no silent type
rewrites” rule: a bare VALUE (implicit
--value-type string) is always a string, so writing one over anything that is not already a string rewrites what is there. That is an argument error, not a coercion decision. Returns what would be overwritten so the caller can name both escape hatches (--value-type <kind>to keep it,--value-type stringto convert deliberately). - scalar_
kind - The scalar kind of
value, orNonefor an array/object. - value_
from_ type - Construct a
Valuefrom a CLI string per an explicitValueType. - value_
matches_ type - Whether
valuesatisfiesexpectedfor a typed read — the GET-side counterpart tovalue_from_type.Jsonmatches any value;Numbermatches every numeric representation; the rest match their one kind. A consumer that asks for a type gets a value back only when it actually is that type, so a wrong-typed leaf is a caught error rather than a surprise.