Skip to main content

rewrite_notes_file

Function rewrite_notes_file 

Source
pub fn rewrite_notes_file(
    notes_path: &Path,
    mutate: impl FnOnce(&mut Vec<NoteEntry>) -> Result<(), NoteError>,
) -> Result<Vec<NoteEntry>, NoteError>
Expand description

Rewrite notes.toml by applying a mutation to the parsed entries.

Reads the file, parses into NoteEntry structs, applies mutate, serializes back with the standard header, and writes atomically. Holds an exclusive file lock for the entire read-modify-write cycle.