English
ours-native-config
crates/native-config — the loader of the native YAML configuration, in-place editing of its text and the format's JSON Schema.
How loading works step by step is in Configuration; here — the crate as a whole.
What it does
load(text, decoders)/load_located/load_with→Loaded/Config: the YAML is read byours-yaml, checked against the native schema (names, references), every section, entity and block goes to its owning module throughDecoders(provided by the kernel —Modules::decoders()). The result isours_api::config::Config, which the kernel takes. Errors point to the YAML line and column.entity.rs— the top level (TOP_LEVEL), inbounds, outbounds, groups, entity blocks (ENTITY_BLOCKS:tls,transport,dial,listener,mux,reload),defaults, subscription servers;rules.rs—routeand rule-sets;dns.rs— thednssection around what its module reads;tree.rs— walking the YAML tree with spans (Map,Origin,Names).edit.rs— in-place editing of the YAML text: replacing/moving an object or list elements, the rest of the document (with comments) is left untouched. Used by the dashboard.schema.rs—json_schema(decoders): the schema for editors (yaml-language-server). The skeleton is built by the loader, block members — from the#[derive(Options)]field tables and the parts that modules describe withProvide::Schema.runtime(view.rs) — the loaded configuration for whatever shows it (the dashboard).is_native_path— whether a file is native by its path (this is how the binary selects-c/-Cfiles).
Who uses it
The binary (app/ours/src/main.rs: reading configuration files and directories, loading), ui (the api feature), ours-testkit. Modules — only in dev dependencies.
Specifics
- Depends only on
ours-api,ours-config,ours-codec,ours-json,ours-yaml— neither on the kernel nor on modules: which sections and types exist the loader learns fromDecoders. - But the list of top-level sections is written by hand:
TOP_LEVELinentity.rs(also the parsing order) and thepartslist inschema.rs. A new section requires a change here — see how-to: a section.
Tests
crates/native-config/tests/: load.rs (loading), schema.rs (shared defaults, templates, references, logic, errors with positions), json_schema.rs (the schema against what the format accepts), subscriptions.rs (names, filters, patches, subscription groups), auto_nft.rs. Shared helpers — crates/native-config/tests/common/. In dev dependencies — almost all modules.