Function write_atomic::write_file

source ·
pub fn write_file<P>(src: P, data: &[u8]) -> Result<()>where
    P: AsRef<Path>,
Expand description

Atomic File Write!

This will write bytes atomically to the specified path, maintaining permissions and ownership if it already exists, or creating it anew using the same default permissions and ownership std::fs::File::create would.

Examples

// It's just one line:
write_atomic::write_file("/path/to/my/file.txt", b"Some data!")
    .unwrap();

Errors

This will bubble up any filesystem-related errors encountered along the way.