Skip to main content

atomic_write

Function atomic_write 

Source
pub fn atomic_write(
    path: &Path,
    write: impl FnOnce(&mut BufWriter<File>) -> Result<()>,
) -> Result<()>
Expand description

Writes a file so that it appears whole or not at all: into a temporary file beside it, then renamed over path (through a symbolic link, to its target). A failure removes the temporary file and leaves path as it was.

ยงErrors

When write fails or the file system refuses.