[][src]Struct zbox::OpenOptions

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]

pub fn new() -> Self[src]

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]

Sets the option for read access.

pub fn write(&mut self, write: bool) -> &mut OpenOptions[src]

Sets the option for write access.

pub fn append(&mut self, append: bool) -> &mut OpenOptions[src]

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]

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]

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]

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]

Sets the maximum number of file versions allowed.

The version_limit must be within [1, 255], default is 1. 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]

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]

Opens a file at path with the options specified by self.

Trait Implementations

impl Default for OpenOptions[src]

impl Debug for OpenOptions[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]