Expand description
Format-neutral in-memory document value, plus a file-backed document facade with safe, source-preserving edits.
DocumentFile lifts the file-safety and source-preserving edit
orchestration that previously lived only in a CLI binary: mutation
methods refuse to write through a symlink or (on unix) a hardlinked
file, and every write goes to a same-directory temp file that is
fsynced, has the original file’s permissions re-applied, and is
atomically renamed over the target — so a crash or error mid-write never
leaves a partial file.
This module never redacts values on decode/encode/save/edit — it reads and writes raw values as-is; redaction is the caller’s responsibility.
§Capability matrix
Document(in-memory):Document::value_mutallows arbitrary in-memory edits;Document::encodere-renders the value fresh from scratch — formatting and comments are NOT preserved. No file, no atomic write.DocumentFile(file-backed): reads viaDocumentFile::value(paired with the free functioncrate::document::get_path), and source-preserving typed write verbsDocumentFile::set/DocumentFile::unset/DocumentFile::add/DocumentFile::remove; every write is atomic (symlink/hardlink-guarded temp file + fsync + permission-preserving rename). There is novalue_mut— edits go through the verbs above so the original source’s formatting survives.
Structs§
- Document
- A format-neutral in-memory document: a parsed
Valueplus theFormatit was parsed from. Has no file or stdin coupling — construct it from a string or anystd::io::Readthe caller supplies. - Document
File - A file-backed document: owns the path, format, original source text, and parsed value.