Skip to main content

atomic_write

Function atomic_write 

Source
pub fn atomic_write(dest: &Path, data: &[u8]) -> Result<()>
Expand description

Atomically replace dest with the contents of src using a rename.

Writes to a temporary file adjacent to dest, then renames it into place. Because rename(2) is atomic on POSIX systems (and atomic at the filesystem level on Windows for files on the same volume), this prevents readers from observing a partially written file.

ยงErrors

Returns an I/O error if the source cannot be read, the temp file cannot be written, or the rename fails.