pub fn write_atomic(path: &Path, bytes: &[u8]) -> Result<()>Expand description
Write bytes to path atomically.
The low-level primitive beneath write_json_atomic; it returns a bare
io::Result because no encoding is involved. Creates any missing parent
directories, writes a sibling temp file, flushes it, then renames it over the
destination. The rename is atomic on the same filesystem, so readers observe
either the old file or the fully written new one — never a partial write. The
temp file is removed on every failure path, and the parent directory is
flushed after a successful rename for durability (best-effort).