Skip to main content

write_atomic

Function write_atomic 

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

Atomically and durably replace path with bytes (see the module docs for the write/fsync/rename/fsync sequence). The parent directory is created if missing. On any early return between temp-file creation and a successful rename — a write_all/sync_all failure (ENOSPC, EIO, quota) as well as a rename failure — the temp file is cleaned up rather than leaked, via the [TempGuard] Drop impl (mirroring index.rs’s AtomicTemp).