English
ours-yaml
libs/yaml — YAML 1.2 text → a tree of values with positions, restricted to what the native schema allows.
Design
- The event parser is
saphyr-parser; the tree isours_json::Nodewith byteSpans, the same thatours-jsonbuilds. So the whole loader and the module decoders work with one node type, and a YAML error and a decoding error point to the line and column the same way. parse(text)→Node;Error(at_span,first_at— "first here",located—line:column: message).
What is forbidden
- more than one document (
a configuration is one YAML document); - anchors, aliases and
<<merge keys — there isdefaultsfor repeated values; - tags;
- non-string keys and repeated keys (the error also points to the first occurrence);
.inf/.nan.
Scalars are resolved by the YAML 1.2 core schema (the numbers 0x, 0o, 1.5e3, ~, true and so on); no is a string, not false.
clash::parse reads YAML as Clash configurations write it: anchors, aliases and merge keys are allowed (with a size cap), tags are ignored, the first document is read. It returns a plain Value; subscriptions use it for Clash configs.
Who uses it
ours-native-config, ours-mod-subscriptions (clash), the binary (ours format) and the allocs tool.
Specifics
Dependencies — saphyr-parser, ours-json.
Tests
Unit tests in src/lib.rs (scalars, prohibitions, messages with positions); the fuzz target parse in fuzz/.