Expand description
Format-preserving edits to a document’s metadata, whatever carries it.
MetaEditor dispatches on the document’s MetaCarrier: a fenced block
is edited with fig’s fig::Embed (fences and body untouched), a config
document with fig’s fig::Editor (the whole file is the metadata).
Either way the edit is comment-preserving and byte-minimal — only the
changed node’s bytes move — and the original carrier and format are never
rewritten into another.
The workspace mutation ops build on this; the free functions are the
single-document surface (the CLI’s set/unset).
Enums§
- Meta
Editor - A comment-preserving editor over a document’s metadata, generic over where the metadata lives.
Functions§
- infer_
scalar - Interpret a CLI-provided scalar:
true/false, integers, floats, andnullbecome their typed values; everything else stays a string. - key_
path - Parse a dotted key path (
a.b.0.c) into fig path segments. An all-digit segment indexes a sequence; anything else names a mapping key. - reformat_
block - Re-emit
mappingas a fresh metadata block of archetypetarget, placed intarget’s canonical position around the plainbody(before it for frontmatter, after it for endmatter) — the reconstruction a format conversion performs. Unlike the comment-preserving edits above, this deliberately rebuilds the block: a conversion crosses formats (a YAML comment has no JSON home), so only the values survive. - set_
in_ text - Upsert
dottedtovalueintext’s metadata (carrier-aware), creating a YAML frontmatter block when the document has none. Returns the full re-rendered document text. - set_
meta_ in_ text - Upsert
dottedto a fullValue— the mapping-valued counterpart toset_in_text, which takes only afig::Valuescalar. Lets a caller set a whole nested block (e.g. the root’sprov:policy block) without namingfig, converting through the crate’sValue → fig::Valuebridge. - unset_
in_ text - Delete the entry at
dottedfromtext’s metadata (carrier-aware). Returns the full re-rendered document text. Errors when the document has no metadata or the path does not exist.