Skip to main content

write_atomic

Function write_atomic 

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

Write and sync a temporary sibling, atomically replace path, then sync its directory. The parent must exist. Concurrent readers see whole versions. A pre-replacement failure leaves the target unchanged; FileError::AfterReplace reports that new bytes are visible but directory syncing failed. Windows requires the POSIX replacement support described by AtomicFile::replace.