Skip to main content

Module file

Module file 

Source
Expand description

Format-neutral document editing: an in-memory Document with source-preserving edits, and a DocumentFile that adds the file boundary.

Document holds the source text, its parsed Value, and the Format. Its verbs — set / unset / add / remove — edit the source in place (comments, ordering, and untouched formatting survive) and update the parsed value alongside; source reads the result and encode re-renders a fresh, non-preserving copy from the value. No file, no I/O, no guards — just editing.

DocumentFile is a Document plus a path, reachable through Deref: read and edit exactly as above, then commit with save or the edit closure. Every write refuses a symlink/hardlinked target and goes to a same-directory temp file that is fsynced, has the original permissions re-applied, and is atomically renamed over the target — so a crash mid-write never leaves a partial file.

This module never redacts values — it reads and writes raw values as-is; redaction is the caller’s responsibility.

Structs§

Document
A format-neutral in-memory document: the original source text, its parsed Value, and the Format both came from. Has no file coupling — construct it from a string or any std::io::Read the caller supplies, edit it source-preservingly with set / unset / add / remove, and read the result back with source. DocumentFile is just this plus a path.
DocumentFile
A file-backed Document: the in-memory document plus the path it was read from.