Struct a10::fs::OpenOptions
source · pub struct OpenOptions { /* private fields */ }
Expand description
Options used to configure how a file (AsyncFd
) is opened.
Implementations§
source§impl OpenOptions
impl OpenOptions
sourcepub const fn new() -> OpenOptions
pub const fn new() -> OpenOptions
Empty OpenOptions
, has reading enabled by default.
sourcepub const fn read(self) -> Self
pub const fn read(self) -> Self
Enable read access.
Note that read access is already enabled by default, so this is only
useful if you called OpenOptions::write_only
and want to enable read
access as well.
sourcepub const fn write_only(self) -> Self
pub const fn write_only(self) -> Self
Only enable write access, disabling read access.
sourcepub const fn create_new(self) -> Self
pub const fn create_new(self) -> Self
Force a file to be created, failing if a file already exists.
This options implies OpenOptions::create
.
sourcepub const fn data_sync(self) -> Self
pub const fn data_sync(self) -> Self
Write operations on the file will complete according to the requirements of synchronized I/O data integrity completion.
By the time write(2)
(and similar) return, the output data has been
transferred to the underlying hardware, along with any file metadata
that would be required to retrieve that data (i.e., as though each
write(2)
was followed by a call to fdatasync(2)
).
sourcepub const fn sync(self) -> Self
pub const fn sync(self) -> Self
Write operations on the file will complete according to the requirements
of synchronized I/O file integrity completion (by contrast with the
synchronized I/O data integrity completion provided by
OpenOptions::data_sync
.)
By the time write(2)
(or similar) returns, the output data and
associated file metadata have been transferred to the underlying
hardware (i.e., as though each write(2)
was followed by a call to
fsync(2)
).
sourcepub const fn direct(self) -> Self
pub const fn direct(self) -> Self
Try to minimize cache effects of the I/O to and from this file.
File I/O is done directly to/from user-space buffers. This uses the
O_DIRECT
flag which on its own makes an effort to transfer data
synchronously, but does not give the guarantees of the O_SYNC
flag
(OpenOptions::sync
) that data and necessary metadata are
transferred. To guarantee synchronous I/O, O_SYNC
must be used in
addition to O_DIRECT
.
sourcepub const fn mode(self, mode: mode_t) -> Self
pub const fn mode(self, mode: mode_t) -> Self
Sets the mode bits that a new file will be created with.
sourcepub fn open_temp_file(self, sq: SubmissionQueue, dir: PathBuf) -> Open ⓘ
pub fn open_temp_file(self, sq: SubmissionQueue, dir: PathBuf) -> Open ⓘ
Create an unnamed temporary regular file. The dir
argument specifies a
directory; an unnamed inode will be created in that directory’s
filesystem. Anything written to the resulting file will be lost when the
last file descriptor is closed, unless the file is given a name.
OpenOptions::write
must be set. The linkat(2)
system call can be
used to make the temporary file permanent.
Trait Implementations§
source§impl Clone for OpenOptions
impl Clone for OpenOptions
source§fn clone(&self) -> OpenOptions
fn clone(&self) -> OpenOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more