Trait OpenOptionsExt
trait OpenOptionsExt
Unix-specific extensions to fs::OpenOptions.
Required Methods
fn mode(self: &mut Self, mode: u32) -> &mut SelfSets the mode bits that a new file will be created with.
If a new file is created as part of an
OpenOptions::opencall then this specifiedmodewill be used as the permission bits for the new file. If nomodeis set, the default of0o666will be used. The operating system masks out bits with the system'sumask, to produce the final permissions.Examples
use std::fs::OpenOptions; use std::os::unix::fs::OpenOptionsExt; # fn main() { let mut options = OpenOptions::new(); options.mode(0o644); // Give read/write for owner and read for others. let file = options.open("foo.txt"); # }fn custom_flags(self: &mut Self, flags: i32) -> &mut SelfPass custom flags to the
flagsargument ofopen.The bits that define the access mode are masked out with
O_ACCMODE, to ensure they do not interfere with the access mode set by Rust's options.Custom flags can only set flags, not remove flags set by Rust's options. This function overwrites any previously-set custom flags.
Examples
# mod libc { pub const O_NOFOLLOW: i32 = 0; } use std::fs::OpenOptions; use std::os::unix::fs::OpenOptionsExt; # fn main() { let mut options = OpenOptions::new(); options.write(true); options.custom_flags(libc::O_NOFOLLOW); let file = options.open("foo.txt"); # }
Implementors
impl OpenOptionsExt for crate::fs::OpenOptions