Skip to main content

write_private

Function write_private 

Source
pub fn write_private(path: &Path, data: &[u8]) -> Result<()>
Expand description

Write data to path, creating or truncating the file with mode 0o600 on Unix.

This is a one-shot convenience wrapper around open_private_truncate that handles write_all and flush. For streaming writes use open_private_truncate directly.

§Errors

Returns the underlying io::Error if the file cannot be created, written to, or flushed.

§Examples

use zeph_common::fs_secure;

fs_secure::write_private(std::path::Path::new("/tmp/dump.json"), b"{}")?;