Struct virtual_fs::OpenOptions
source · pub struct OpenOptions<'a> {
pub(crate) opener: &'a dyn FileOpener,
pub(crate) conf: OpenOptionsConfig,
}
Fields§
§opener: &'a dyn FileOpener
§conf: OpenOptionsConfig
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.