Skip to main content

Module path

Module path 

Source
Expand description

Canonical document-model paths.

DocPath is the workspace’s one serializer and parser for Diagnostic::path — the anchor into a typed Document. Every emit site (schema validation, !must_fill collection, coercion) constructs a DocPath and renders it once through Display; no site assembles a path with format!, and no consumer regexes one back apart — the exported FromStr parser is the inverse.

§Grammar

path   := root segment*
root   := "main"                          // the main card
        | "cards" "." kind "[" index "]"   // typed card
        | "cards" "[" index "]"            // unknown-kind card (the only bare-index root)
segment:= "." field | "[" index "]" | ".body"
kind   := [a-z_][a-z0-9_]*
field  := [A-Za-z_][A-Za-z0-9_]*

Every document-model path is rooted: a main field is main.<field> (main.title, main.recipients[0].name), the main body main.body. A card field is kind-qualified — cards.<kind>[<i>].<field> — so a consumer receives kind and array index without a second lookup; a card whose $kind has no schema — absent, or present but not a declared card kind — stays cards[<i>]. Field names and card kinds exclude ., [, ], so the rendered form round-trips.

Rooting makes the grammar total against a field named for a root: a main field literally named cards or main is main.cards / main.main, which no longer collides. One residual: a field literally named body renders <root>.body and collides with the body terminal — accepted, not guarded (no fixture field uses the name).

This is the document-model namespace, distinct from the plate-JSON data.$cards array template authors see (prose/canon/CARDS.md): sigiled $cards is glue delivered to the backend, unsigiled cards is a path into the document. Config-space anchors ($seed.<kind>.<field>, Quill.yaml schema-literal owner labels) ride the same serializer with their prefix as a leading field segment — the one unrooted form, config-space not document-model, verbatim and never parsed.

Structs§

DocPath
A canonical document-model path — an ordered DocSeg list with one Display serializer and one FromStr parser. See the module docs for the grammar.
DocPathParseError
A DocPath parse failure. Carries the offending input for a diagnostic message; the parser is total over every path Display emits.

Enums§

DocSeg
One segment of a DocPath.