03 / CONTROL
conf
The canonical config-key form: lowercased, _ and - dropped, so MaxBytes, maxBytes, max_bytes and max-bytes all name one field and a config document written in any of them loads unchanged.
WHERE IT SITS
INTERFACE
fn canonical_key(key : String) -> Stringfncanonical form for a config key: lowercased, with _ and - dropped. Every lookup compares on this form, so MaxBytes, maxBytes, max_bytes and max-bytes all name one field — which is what lets a genuine etc/*.yaml, whose keys are all PascalCase, load into a config instead of silently yielding defaults.
struct ConfstructA loaded config document: a parsed mapping read through canonical keys and dotted paths, with the ,env=NAME override and the default= / options= / range= constraints spells as struct tags. A field that is absent and has no default is an error, and so is a value that violates its options= or range= constraint — a bad value never degrades into the default.
fn Conf::of_json( src : String, vars? : @expand.Vars, knobs? : @expand.Knobs) -> Conf raise RefusedfnLoad a document from JSON. Raises Refused on malformed JSON or a non-object root. With vars, ${NAME} and $NAME in the text are replaced first); knobs says what an unset name becomes, an empty string by default as with Go's os.ExpandEnv`.
fn Conf::of_yaml( src : String, vars? : @expand.Vars, knobs? : @expand.Knobs) -> Conf raise RefusedfnLoad a document from the YAML ships as etc/*.yaml. Raises Refused on malformed YAML or a non-mapping root. vars and knobs are as for of_json.
fn Conf::of_toml( src : String, vars? : @expand.Vars, knobs? : @expand.Knobs) -> Conf raise RefusedfnLoad a document from TOML, the third format conf.Load reads. Raises Refused on malformed TOML. vars and knobs are as for of_json.
fn Conf::at(self : Conf, path : String) -> Json?fnThe value at a dotted path, or None if any segment is missing or a non-mapping is walked into.
fn Conf::string( self : Conf, path : String, default? : String, options? : Array[String], env? : String, also~ : Array[String] = []) -> String raise RefusedfnRead a string field, honouring env=, default= and options=.
fn Conf::int( self : Conf, path : String, default? : Int32, range? : String, env? : String, also~ : Array[String] = []) -> Int32 raise RefusedfnRead an Int field, honouring env=, default= and range=. A fractional value is truncated toward zero after the range check.
fn Conf::int64( self : Conf, path : String, default? : Int64, range? : String, env? : String, also~ : Array[String] = []) -> Int64 raise RefusedfnRead an Int64 field, honouring env=, default= and range=.
fn Conf::bool( self : Conf, path : String, default? : Bool, env? : String, also~ : Array[String] = []) -> Bool raise RefusedfnRead a Bool field, honouring env= and default=. true/false spelled as a string decode too, which is how an env override arrives.
fn Conf::strings( self : Conf, path : String, default? : Array[String], env? : String, also~ : Array[String] = []) -> Array[String] raise RefusedfnRead a string-list field, honouring env= and default=. An env override is comma-separated, since a shell variable carries one string.
fn Conf::list(self : Conf, path : String) -> Array[Conf] raise RefusedfnThe list of sub-documents at path — the shape a []Struct config field takes, each element read back through the same constraint-checked accessors. An absent path is an empty list; a non-list, or a list holding anything but mappings, is an error.