Skip to main content

atomic_write

Function atomic_write 

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

Write data to path atomically by writing to a temporary sibling file and then renaming it into place.

The temp file is created in the same directory as path to guarantee same-filesystem rename semantics.

ยงErrors

Returns an error if:

  • The parent directory of path does not exist.
  • The temp file cannot be created or written.
  • The rename operation fails.