Struct zbox::OpenOptions [−][src]
pub struct OpenOptions { /* fields omitted */ }
Options and flags which can be used to configure how a file is opened.
This builder exposes the ability to configure how a File
is opened and
what operations are permitted on the opened file. The Repo::open_file
and Repo::create_file
methods are aliases for commonly used options
using this builder.
Generally speaking, when using OpenOptions
, you'll first call new
, then
chain calls to methods to set each option, then call open
, passing the
path of the file you're trying to open. This will give you a Result
with a File
inside that you can further operate on.
Examples
Opening a file for both reading and writing, as well as creating it if it doesn't exist.
let file = OpenOptions::new() .read(true) .write(true) .create(true) .open(&mut repo, "/foo.txt")?;
Methods
impl OpenOptions
[src]
impl OpenOptions
pub fn new() -> Self
[src]
pub fn new() -> Self
Creates a blank new set of options ready for configuration.
All options are initially set to false, except for read
.
pub fn read(&mut self, read: bool) -> &mut OpenOptions
[src]
pub fn read(&mut self, read: bool) -> &mut OpenOptions
Sets the option for read access.
pub fn write(&mut self, write: bool) -> &mut OpenOptions
[src]
pub fn write(&mut self, write: bool) -> &mut OpenOptions
Sets the option for write access.
pub fn append(&mut self, append: bool) -> &mut OpenOptions
[src]
pub fn append(&mut self, append: bool) -> &mut OpenOptions
Sets the option for the append mode.
This option, when true, means that writes will append to a file instead
of overwriting previous content. Note that setting
.write(true).append(true)
has the same effect as setting only
.append(true)
.
pub fn truncate(&mut self, truncate: bool) -> &mut OpenOptions
[src]
pub fn truncate(&mut self, truncate: bool) -> &mut OpenOptions
Sets the option for truncating a previous file.
Note that setting .write(true).truncate(true)
has the same effect as
setting only .truncate(true)
.
pub fn create(&mut self, create: bool) -> &mut OpenOptions
[src]
pub fn create(&mut self, create: bool) -> &mut OpenOptions
Sets the option for creating a new file.
This option indicates whether a new file will be created if the file does not yet already exist.
pub fn create_new(&mut self, create_new: bool) -> &mut OpenOptions
[src]
pub fn create_new(&mut self, create_new: bool) -> &mut OpenOptions
Sets the option to always create a new file.
This option indicates whether a new file will be created. No file is allowed to exist at the target location.
pub fn version_limit(&mut self, version_limit: u8) -> &mut OpenOptions
[src]
pub fn version_limit(&mut self, version_limit: u8) -> &mut OpenOptions
Sets the maximum number of file versions allowed.
The version_limit
must be within [1, 255]. It will fall back to
repository's version_limit
if it is not set.
pub fn dedup_chunk(&mut self, dedup_chunk: bool) -> &mut OpenOptions
[src]
pub fn dedup_chunk(&mut self, dedup_chunk: bool) -> &mut OpenOptions
Sets the option for file data chunk deduplication.
This option indicates whether data chunk should be deduped when
writing data to a file. It will fall back to repository's
dedup_chunk
if it is not set.
pub fn open<P: AsRef<Path>>(&self, repo: &mut Repo, path: P) -> Result<File>
[src]
pub fn open<P: AsRef<Path>>(&self, repo: &mut Repo, path: P) -> Result<File>
Opens a file at path with the options specified by self
.
Trait Implementations
impl Debug for OpenOptions
[src]
impl Debug for OpenOptions
Auto Trait Implementations
impl Send for OpenOptions
impl Send for OpenOptions
impl Sync for OpenOptions
impl Sync for OpenOptions