pub struct OpenOptions {
pub read: bool,
pub write: bool,
pub create: bool,
pub create_new: bool,
pub truncate: bool,
pub append: bool,
}Expand description
Options for opening a file.
This struct provides a builder-style API for configuring how a file
should be opened, similar to std::fs::OpenOptions.
Fields§
§read: boolOpen file for reading.
write: boolOpen file for writing.
create: boolCreate the file if it doesn’t exist.
create_new: boolCreate a new file, failing if it already exists.
truncate: boolTruncate the file to zero length.
append: boolAppend to the end of the file.
Implementations§
Source§impl OpenOptions
impl OpenOptions
Sourcepub fn new() -> OpenOptions
pub fn new() -> OpenOptions
Create new open options with all flags set to false.
Sourcepub fn read(self, read: bool) -> OpenOptions
pub fn read(self, read: bool) -> OpenOptions
Set the read flag.
Sourcepub fn write(self, write: bool) -> OpenOptions
pub fn write(self, write: bool) -> OpenOptions
Set the write flag.
Sourcepub fn create(self, create: bool) -> OpenOptions
pub fn create(self, create: bool) -> OpenOptions
Set the create flag.
Sourcepub fn create_new(self, create_new: bool) -> OpenOptions
pub fn create_new(self, create_new: bool) -> OpenOptions
Set the create_new flag.
Sourcepub fn truncate(self, truncate: bool) -> OpenOptions
pub fn truncate(self, truncate: bool) -> OpenOptions
Set the truncate flag.
Sourcepub fn append(self, append: bool) -> OpenOptions
pub fn append(self, append: bool) -> OpenOptions
Set the append flag.
Sourcepub fn read_only() -> OpenOptions
pub fn read_only() -> OpenOptions
Create options for read-only access.
Sourcepub fn create_write() -> OpenOptions
pub fn create_write() -> OpenOptions
Create options for creating and writing a new file (truncating if exists).
Sourcepub fn read_write() -> OpenOptions
pub fn read_write() -> OpenOptions
Create options for read and write access.
Sourcepub fn create_new_write() -> OpenOptions
pub fn create_new_write() -> OpenOptions
Create options for creating a new file for writing (fails if exists).
Trait Implementations§
Source§impl Clone for OpenOptions
impl Clone for OpenOptions
Source§fn clone(&self) -> OpenOptions
fn clone(&self) -> OpenOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpenOptions
impl Debug for OpenOptions
Source§impl Default for OpenOptions
impl Default for OpenOptions
Source§fn default() -> OpenOptions
fn default() -> OpenOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OpenOptions
impl RefUnwindSafe for OpenOptions
impl Send for OpenOptions
impl Sync for OpenOptions
impl Unpin for OpenOptions
impl UnsafeUnpin for OpenOptions
impl UnwindSafe for OpenOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more