pub fn decode_front_matter(src: &str) -> Result<Option<Value>, DecodeError>Expand description
Front-matter-only decode. Scans leading trivia, the opening +++,
the front-matter contents, and the closing +++, then stops — body
bytes are NOT tokenized. Required at SPEC tier 0; see SPEC
§“Front-matter-only decode” for the full contract.
Return value:
Ok(None)— the document has no front matter at all (no opening+++after leading trivia).Ok(Some(Value::Table(map)))— front matter was present.mapis empty when the source carried+++\n+++\nwith no inner keys, so callers can distinguish “no front matter” from “present-but-empty”.Err(DecodeError)— every front-matter rule still applies: open/close on their own lines, unterminated front matter is an error, the_-prefix namespace is enforced (_dms_tieris type-checked, unknown reserved keys rejected). Diagnostics inside the+++ ... +++block are byte-identical to a full decode.
Errors that only manifest in the body (duplicate body keys,
unterminated body heredoc, …) are NOT surfaced — that’s the entire
point of this entry point. Callers needing whole-document validation
must use decode_document.
Runs in lite mode (no comment AST, no original_forms).