The tomlsmith crate provides parsing, diagnostics, formatting, highlighting, and decoded values through an immutable Document API.
Document is an immutable snapshot. Parse once, then query diagnostics, formatted output, highlight spans, and decoded values from the same object. Formatting with a different target version performs a separate safety parse; reusable integrations should keep the parse and format versions aligned.
| Area | What you get |
|---|---|
| Parsing | Lossless syntax tree for TOML 1.0 or 1.1, selected explicitly per parse |
| Diagnostics | Errors and warnings with exact source spans and stable codes |
| Formatting | Formatted output that preserves comments and literal spellings in covered cases |
| Highlighting | Semantic highlight spans produced by the same parse |
| Decoded values | Keys, tables, and values for programmatic access |
The parse call accepts TomlVersion::V1_0 or TomlVersion::V1_1. An application can hold documents of both versions at the same time. Document::parse defaults to 1.1; prefer explicit selection in reusable integrations. See the version policy.
crates/tomlsmith, plus the CLI and LSP crates built on top of it.