### Write config.json atomically with AtomicWriteFile Source: https://github.com/andreacorbellini/rust-atomic-write-file/blob/master/README.md Shows the atomic alternative using AtomicWriteFile and commit(). If interrupted before commit(), the original file remains untouched; only after full write does config.json get updated. ```rust use std::io::Write; use atomic_write_file::AtomicWriteFile; let mut file = AtomicWriteFile::options() .open("config.json")?; writeln!(file, "{{")?; writeln!(file, " \"key1\": \"value1\",")?; writeln!(file, " \"key2\": \"value2\"")?; writeln!(file, "}}")?; file.commit()?; ``` -------------------------------- ### Run crash tests with default settings Source: https://github.com/andreacorbellini/rust-atomic-write-file/blob/master/crash-tests/linux/README.md Executes the test suite using the current kernel and the ext4 filesystem. ```sh ./run-tests.sh ``` -------------------------------- ### Run crash tests with custom settings Source: https://github.com/andreacorbellini/rust-atomic-write-file/blob/master/crash-tests/linux/README.md Executes the test suite with a custom kernel path, a specific filesystem type, and additional cargo features. ```sh ./run-tests.sh --kernel path/to/my-custom-vmlinuz --filesystem-type btrfs --cargo-features unnamed-tmpfile ``` -------------------------------- ### Write config.json with std::fs::File Source: https://github.com/andreacorbellini/rust-atomic-write-file/blob/master/README.md Shows the non-atomic approach using std::fs::File to write a JSON configuration file. If interrupted before all writes complete, the file is left in a broken state and original contents are lost. ```rust use std::io::Write; use std::fs::File; let mut file = File::options() .write(true) .create(true) .open("config.json")?; writeln!(file, "{{")?; writeln!(file, " \"key1\": \"value1\",")?; writeln!(file, " \"key2\": \"value2\"")?; writeln!(file, "}}")?; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.