pub struct Options { /* private fields */ }Expand description
How Options::write and Options::write_with replace a file.
The defaults are the safe ones: fsync, keep permissions, keep symlinks, and do not create missing directories.
Implementations§
Source§impl Options
impl Options
pub fn new() -> Self
Sourcepub fn durable(self, on: bool) -> Self
pub fn durable(self, on: bool) -> Self
Fsync the file before the rename and its directory after it (default on). Without the file fsync the kernel may record the rename and lose the bytes, leaving an empty file after a crash.
Sourcepub fn preserve_permissions(self, on: bool) -> Self
pub fn preserve_permissions(self, on: bool) -> Self
Copy an existing target’s permissions onto the new file (default on), so a 0600 file stays 0600. On Windows this clears the target’s read-only bit instead, because the rename cannot replace a read-only file.
Sourcepub fn follow_symlinks(self, on: bool) -> Self
pub fn follow_symlinks(self, on: bool) -> Self
When the target is a symlink, write the file it points to and keep the link (default on). Off replaces the link itself with a plain file.
Sourcepub fn create_parent(self, on: bool) -> Self
pub fn create_parent(self, on: bool) -> Self
Create the target’s missing parent directories (default off).
Sourcepub fn mode(self, mode: u32) -> Self
pub fn mode(self, mode: u32) -> Self
Unix mode of the new file. An existing target’s permissions still win
while preserve_permissions is on.