Function atomic_ write
pub fn atomic_write(
path: impl AsRef<Path>,
bytes: &[u8],
) -> Result<(), FileError>Expand description
Create parent directories, write an exclusive same-directory temporary, flush its content, then atomically replace the destination on supported OSes. A failed replacement preserves the old destination and cleans the temporary. Does not sync the parent directory or promise power-loss durability.
ravet_runtime::files::atomic_write(path, b"complete state")?;
assert_eq!(ravet_runtime::files::read(path, 32)?, b"complete state");