Crate write_atomic
source · [−]Expand description
Write Atomic
ALPHA: Note this crate is a work-in-progress and is not yet ready for production use.
Write Atomic is a stripped-down remake of tempfile-fast
, boiling everything down to a single method: write_file
.
Like tempfile-fast
, bytes will first be written to a temporary file — either O_TMPFILE
on supporting Linux systems or via the tempfile
crate — then moved the final destination.
When overwriting an existing file, permissions and ownership will be preserved, otherwise the permissions and ownership will default to the same values you’d get if using std::fs::File::create
.
Because there is just a single write_file
method, this crate is only really suitable in cases where you have the path and all the bytes you want to write ready to go. If you need more granular Read
/Seek
/Write
support, use tempfile-fast
instead.
Examples
// One line is all it takes:
write_atomic::write_file("/path/to/my-file.txt", b"Some data!").unwrap();
Installation
Add write_atomic
to your dependencies
in Cargo.toml
, like:
[dependencies]
write_atomic = "0.2.*"
Functions
Atomic File Write!