Skip to main content

atomic_write

Function atomic_write 

Source
pub fn atomic_write(target: &Path, content: &[u8]) -> Result<String, Error>
Expand description

Atomically write content to a file using temp-file-then-rename.

The temp file is created in the same directory as target to guarantee a same-filesystem rename (atomic on POSIX). Preserves the permissions of an existing target file if one exists. Creates parent directories as needed.

Returns the SHA256 hex digest of the written content.