Skip to main content

replace_private

Function replace_private 

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

Replace path with bytes atomically, as a file only the user can read.

The bytes go to a temporary file in the same directory, which is synced and renamed over path; the directory is then synced so the rename itself survives a crash. A reader sees the old file or the new one, never a partial write. The directory must exist; callers create it with the privacy their data needs.