Skip to main content

atomic_write

Function atomic_write 

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

Atomically write content to a file.

  1. Create a temporary file alongside the target path.
  2. Write all content.
  3. Flush the stream.
  4. fsync the file (ensures data hits the disk).
  5. Rename the temp file to the target path (atomic on Unix).

ยงArguments

  • path - The final file path to write.
  • content - The bytes to write.