Skip to main content

atomic_write

Function atomic_write 

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

Atomically replace path with bytes.

Writes to a uniquified sibling temp file then renames into place. The parent directory must exist; it will not be created.

On Unix, if path is a symlink, its pointee is resolved and replaced — the symlink itself is preserved. On Windows the symlink is replaced with a regular file (with a tracing::warn!).

§Errors

Returns io::Error if the write or rename fails.