Skip to main content

atomic_write

Function atomic_write 

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

Atomically writes bytes to path (temp file in the same dir + rename).

The temp file has a name of its own (see create_unique_temp_file), and when path already exists it takes over that file’s permissions — a rename replaces the inode, and a note that was 0600 must not come back 0644. The temp file is removed on any failure. Blocking.

Does not lock: callers that read before writing hold a per-file lock across both (mbr_server::file_write::FileWriteLocks).