OpenOptions

Struct OpenOptions 

Source
pub struct OpenOptions<Access: AccessMode, Open: OpenMode> { /* private fields */ }
Available on Linux only.
Expand description

A builder struct to help with opening files, using customizable options and logical defaults. Available via File::options to avoid additional use statements.

Implementations§

Source§

impl<A: AccessMode, O: OpenMode> OpenOptions<A, O>

Source

pub fn new() -> OpenOptions<A, O>

Source

pub const fn no_create(self) -> OpenOptions<A, NoCreate>

Source

pub const fn create_if_missing(self) -> OpenOptions<A, CreateIfMissing>

Source

pub const fn create_or_empty(self) -> OpenOptions<A, CreateOrEmpty>

Source

pub const fn create(self) -> OpenOptions<A, Create>

Source

pub const fn write_only(self) -> OpenOptions<WriteOnly, O>

Source

pub const fn read_write(self) -> OpenOptions<ReadWrite, O>

Source

pub const fn mode(&mut self, value: u16) -> &mut Self

Source

pub const fn append(&mut self, value: bool) -> &mut Self

Source

pub const fn force_sync(&mut self, value: bool) -> &mut Self

Source

pub const fn update_access_time(&mut self, value: bool) -> &mut Self

Source

pub const unsafe fn extra_flags(&mut self, value: i32) -> &mut Self

Source§

impl<A: AccessMode, O: Permanent> OpenOptions<A, O>

Source

pub const fn read_only(self) -> OpenOptions<ReadOnly, O>

Source§

impl<A: Write, O: OpenMode> OpenOptions<A, O>

Source

pub const fn create_temp(self) -> OpenOptions<A, CreateTemp>

Source

pub const fn create_unlinked(self) -> OpenOptions<A, CreateUnlinked>

Source§

impl<A: AccessMode> OpenOptions<A, NoCreate>

Source

pub fn open<P: Into<OwnedPath<Abs>>>( &self, file_path: P, ) -> Result<File<A>, OpenError>

Source

pub fn open_rel<P: Into<OwnedPath<Rel>>>( &self, relative_to: &Directory, file_path: P, ) -> Result<File<A>, OpenError>

Source

pub fn open_dir_entry( &self, dir_ent: &DirEntry<'_>, ) -> Result<File<A>, OpenError>

Source§

impl<A: AccessMode> OpenOptions<A, CreateIfMissing>

Source

pub fn open<P: Into<OwnedPath<Abs>>>( &self, file_path: P, ) -> Result<File<A>, OpenError>

Source

pub fn open_rel<P: Into<OwnedPath<Rel>>>( &self, relative_to: &Directory, file_path: P, ) -> Result<File<A>, OpenError>

Source

pub fn open_dir_entry( &self, dir_ent: &DirEntry<'_>, ) -> Result<File<A>, OpenError>

Source§

impl<A: AccessMode> OpenOptions<A, CreateOrEmpty>

Source

pub fn open<P: Into<OwnedPath<Abs>>>( &self, file_path: P, ) -> Result<File<A>, OpenError>

Source

pub fn open_rel<P: Into<OwnedPath<Rel>>>( &self, relative_to: &Directory, file_path: P, ) -> Result<File<A>, OpenError>

Source

pub fn open_dir_entry( &self, dir_ent: &DirEntry<'_>, ) -> Result<File<A>, OpenError>

Source§

impl<A: AccessMode> OpenOptions<A, Create>

Source

pub fn open<P: Into<OwnedPath<Abs>>>( &self, file_path: P, ) -> Result<File<A>, CreateError>

Source

pub fn open_rel<P: Into<OwnedPath<Rel>>>( &self, relative_to: &Directory, file_path: P, ) -> Result<File<A>, CreateError>

Source§

impl<A: AccessMode> OpenOptions<A, CreateTemp>

Source

pub fn open<P: Into<OwnedPath<Abs>>>( &self, dir_path: P, ) -> Result<File<A>, TempError>

Source

pub fn open_rel(&self, relative_to: &Directory) -> Result<File<A>, TempError>

Source§

impl<A: AccessMode> OpenOptions<A, CreateUnlinked>

Source

pub fn open<P: Into<OwnedPath<Abs>>>( &self, dir_path: P, ) -> Result<File<A>, TempError>

Source

pub fn open_rel(&self, relative_to: &Directory) -> Result<File<A>, TempError>

Trait Implementations§

Source§

impl<Access: Clone + AccessMode, Open: Clone + OpenMode> Clone for OpenOptions<Access, Open>

Source§

fn clone(&self) -> OpenOptions<Access, Open>

Returns a duplicate 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<A: AccessMode, O: OpenMode> Debug for OpenOptions<A, O>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<A: AccessMode, O: OpenMode> Default for OpenOptions<A, O>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Access, Open> Freeze for OpenOptions<Access, Open>

§

impl<Access, Open> RefUnwindSafe for OpenOptions<Access, Open>

§

impl<Access, Open> Send for OpenOptions<Access, Open>

§

impl<Access, Open> Sync for OpenOptions<Access, Open>

§

impl<Access, Open> Unpin for OpenOptions<Access, Open>

§

impl<Access, Open> UnwindSafe for OpenOptions<Access, Open>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.