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

source

pub const fn new() -> OpenOptions

Empty OpenOptions, has reading enabled by default.

source

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.

source

pub const fn write(self) -> Self

Enable write access.

source

pub const fn write_only(self) -> Self

Only enable write access, disabling read access.

source

pub const fn append(self) -> Self

Set writing to append only mode.

§Notes

This requires writing access to be enabled.

source

pub const fn truncate(self) -> Self

Truncate the file if it exists.

source

pub const fn create(self) -> Self

If the file doesn’t exist create it.

source

pub const fn create_new(self) -> Self

Force a file to be created, failing if a file already exists.

This options implies OpenOptions::create.

source

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)).

source

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)).

source

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.

source

pub const fn mode(self, mode: mode_t) -> Self

Sets the mode bits that a new file will be created with.

source

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.

source

pub fn open(self, sq: SubmissionQueue, path: PathBuf) -> Open

Open path.

Trait Implementations§

source§

impl Clone for OpenOptions

source§

fn clone(&self) -> OpenOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for OpenOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.