pub struct OpenOptions<'a> { /* private fields */ }
Implementations§
Source§impl<'a> OpenOptions<'a>
impl<'a> OpenOptions<'a>
pub fn new(opener: &'a dyn FileOpener) -> Self
pub fn get_config(&self) -> OpenOptionsConfig
Sourcepub fn options(&mut self, options: OpenOptionsConfig) -> &mut Self
pub fn options(&mut self, options: OpenOptionsConfig) -> &mut Self
Use an existing OpenOptionsConfig
to configure this OpenOptions
.
Sourcepub fn read(&mut self, read: bool) -> &mut Self
pub fn read(&mut self, read: bool) -> &mut Self
Sets the option for read access.
This option, when true, will indicate that the file should be
read
-able if opened.
Sourcepub fn write(&mut self, write: bool) -> &mut Self
pub fn write(&mut self, write: bool) -> &mut Self
Sets the option for write access.
This option, when true, will indicate that the file should be
write
-able if opened.
If the file already exists, any write calls on it will overwrite its contents, without truncating it.
Sourcepub fn append(&mut self, append: bool) -> &mut Self
pub fn append(&mut self, append: bool) -> &mut Self
Sets the option for the append mode.
This option, when true, means that writes will append to a file instead
of overwriting previous contents.
Note that setting .write(true).append(true)
has the same effect as
setting only .append(true)
.
Sourcepub fn truncate(&mut self, truncate: bool) -> &mut Self
pub fn truncate(&mut self, truncate: bool) -> &mut Self
Sets the option for truncating a previous file.
If a file is successfully opened with this option set it will truncate the file to 0 length if it already exists.
The file must be opened with write access for truncate to work.
Sourcepub fn create(&mut self, create: bool) -> &mut Self
pub fn create(&mut self, create: bool) -> &mut Self
Sets the option to create a new file, or open it if it already exists.
Sourcepub fn create_new(&mut self, create_new: bool) -> &mut Self
pub fn create_new(&mut self, create_new: bool) -> &mut Self
Sets the option to create a new file, failing if it already exists.