Expand description
TC.1: ConfigSchema / ConfigValue — what an option’s value is shaped
like, as data, plus schema-checked validation that reports a path.
TC.1 — what an option’s value is shaped like, as data.
Design: typed-configuration.md.
Options have always been typed on the Rust side — Option<T> over an
OptionType. What they have never been is typed to
anything that is not Rust. The type-erased surface every runtime-name
consumer goes through (:set, the TOML loader, plugin introspection,
:describe-option) exposed a type_label(): &str and a formatted String,
and a label plus a string is not enough to render a composite, validate a
field, or write a value back to TOML.
ConfigSchema is that description and ConfigValue is a value shaped
by it. Together they are what makes design §5.12’s :customize — “a
type-aware editing buffer” — possible at all, and what lets a plugin declare
a record without the host needing a Rust type for it (WIT has no generics;
self-description is the expressible answer).
Additive by construction. parse / format keep their round-trip
contract and remain the :set surface, because a command line is a text
surface and typing a record into one is not an improvement. A scalar option
behaves identically before and after this module existed — its schema is
derived from what it already declares rather than written by hand.
Structs§
- Schema
Error - A validation failure, carrying where it happened.
- Schema
Field - One field of a
ConfigSchema::Record.
Enums§
- Config
Schema - The declared shape of an option’s value.
- Config
Value - A value shaped by a
ConfigSchema. - Scalar
Kind - The leaf kinds. Deliberately the three the ABI already carries plus nothing: a float would need a parse/format round-trip that survives every locale and every plugin language’s formatter, and no option in the workspace wants one. Adding it later is additive; guessing now is not.
Functions§
- config_
value_ to_ toml - A
ConfigValueas TOML. The inverse oftoml_to_config_value, used byConfigValue’sformat()— which is what:set foo?echoes and what:describe-optionshows. - dot_
path - Join a schema path onto an option name. A record field needs the separating
dot (
opt+target.file); an index does not (opt+[2]). - toml_
to_ config_ value - TC.2 — a TOML value as a
ConfigValuetree. - validate
- Check
valueagainstschema, reporting the first failure with its path.