Skip to main content

write_atomic

Function write_atomic 

Source
pub fn write_atomic(path: &Path, contents: &str) -> Result<()>
Expand description

Replace path with contents atomically: write a sibling temporary file, flush it, then rename it over the target. A reader sees either the old or the new file, never a partial write. Existing permissions are kept. A directory-sync failure after replacement is logged, not returned as an uncommitted write. Callers needing that warning use the richer internal API.