Struct zbox::OpenOptions[][src]

pub struct OpenOptions { /* fields omitted */ }
Expand description

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")?;

Implementations

Creates a blank new set of options ready for configuration.

All options are initially set to false, except for read.

Sets the option for read access.

Sets the option for write access.

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).

Sets the option for truncating a previous file.

Note that setting .write(true).truncate(true) has the same effect as setting only .truncate(true).

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.

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.

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.

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.

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

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.