Skip to main content

write_atomically

Function write_atomically 

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

Write contents to path so that dying partway through leaves the previous contents intact: the bytes land in a sibling temporary file, are flushed to the storage device, and only then replace path with one atomic rename.

The target is never opened for writing, so there is no window in which it holds a partial document.