Skip to main content

write_atomic_replace

Function write_atomic_replace 

Source
pub fn write_atomic_replace(
    dest: &Path,
    bytes: impl AsRef<[u8]>,
    temp_prefix: &str,
) -> AppResult<()>
Expand description

Atomically write bytes and replace an existing destination when supported.

Replacing an existing destination is atomic on Unix-like platforms. On Windows, this helper removes the existing file before persisting the temp file because the platform rename operation cannot replace an existing file.