Skip to main content

Module toml_doc

Module toml_doc 

Source
Expand description

P7.3 (#1303): a minimal typed TOML tree and printer — the one piece of R7.8 (Artefacts is a keyed set of typed documents, never a String at construction) landable ahead of bynk-ts (Arc B, P7.5+), since wrangler.toml is the one document bynk-emit produces that isn’t TypeScript. Not a general TOML library: TomlValue represents exactly what emitter::wrangler::emit_wrangler_toml needs to build a wrangler.toml today, no more.

print_toml_document is the only function in this crate that writes TOML syntax — emit_wrangler_toml builds a TomlDocument, this module renders it. That split is what makes string-escaping a printer guarantee (every TomlValue::Str is escaped unconditionally, §“Decision B” of #1303) rather than a per-call-site judgement call, which is what left wrangler.rs’s own name/binding/class_name values unescaped before this — safe today only because those particular values happen to be compiler-derived identifiers that can’t contain a TOML-breaking character, not because anything enforced it structurally.

Structs§

TomlDocument
A TOML document: the root block’s entries (review of #1304, finding 3 — a field set once at construction, not a TomlBlock a caller could accidentally push_block out of first position, which push_block itself couldn’t have rejected: TOML has no marker distinguishing “the root block” from “a table block with no header” once both are just entries in the same list) followed by any number of headed blocks. Every block, printed — root included — is followed by exactly one blank line (including the last — confirmed against every current expected/**/wrangler.toml golden fixture, which all end in a trailing blank line).

Functions§

print_toml_document
Render doc to TOML text. The one function in this module — and, per this file’s own module doc, in bynk-emit’s TOML-producing surface — that calls write!/writeln!/format! to build TOML syntax.