Struct zbox::RepoOpener[][src]

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

A builder used to create a repository Repo in various manners.

This builder exposes the ability to configure how a Repo is opened and what operations are permitted on the opened repository.

Generally speaking, when using RepoOpener, you’ll first call new, then chain calls to methods to set each option, then call open, passing the URI of the repository and password you’re trying to open. This will give you a Result with a Repo inside that you can further operate on.

Examples

Opening a repository and creating it if it doesn’t exist.

use zbox::RepoOpener;

let mut repo = RepoOpener::new().create(true).open("mem://foo", "pwd")?;

Specify options for creating a repository.

use zbox::{RepoOpener, OpsLimit, MemLimit, Cipher};

let mut repo = RepoOpener::new()
    .ops_limit(OpsLimit::Moderate)
    .mem_limit(MemLimit::Interactive)
    .cipher(Cipher::Xchacha)
    .create(true)
    .open("mem://foo", "pwd")?;

Implementations

Creates a blank new set of options ready for configuration.

Sets the password hash operation limit.

This option is only used for creating a repository. OpsLimit::Interactive is the default.

Sets the password hash memory limit.

This option is only used for creating a repository. MemLimit::Interactive is the default.

Sets the crypto cipher encrypts the repository.

This option is only used for creating a repository. Cipher::Aes is the default if CPU supports AES-NI instructions, otherwise it will fall back to Cipher::Xchacha.

Sets the option for creating a new repository.

This option indicates whether a new repository will be created if the repository does not yet already exist.

Sets the option to always create a new repository.

This option indicates whether a new repository will be created. No repository is allowed to exist at the target path.

Sets the option for data compression.

This options indicates whether the LZ4 compression should be used in the repository. Default is false.

This option is only used when creating a repository.

Sets the default maximum number of file version.

The version_limit must be within [1, 255], default is 1. This setting is a repository-wise setting, individual file can overwrite it by setting version_limit in OpenOptions.

Sets the default option for file data chunk deduplication.

This option indicates whether data chunk should be deduped when writing data to a file. This setting is a repository-wise setting, individual file can overwrite it by setting dedup_chunk in OpenOptions. Default is false.

Sets the default option for file deduplication.

This option indicates whether whole file content should be deduped when writing data to repo. Default is false.

This option is only used when creating a repository.

Sets the option for read-only mode.

This option cannot be true with either create or create_new is true.

Sets the option to open repo regardless repo lock.

Normally, repo will be exclusively locked once it is opened. But when this option is set to true, the repo will be opened regardless the repo lock. This option breaks exclusive access to repo, so use it cautiously. Default is false.

Opens a repository at URI with the password and options specified by self.

In general, the URI is structured as follows:

storage://username:password@/path/data?key=value&key2=value2
|------| |-----------------||---------||-------------------|
    |             |              |                |
identifier    authority         path          parameters

Only identifier and path are required, all the others are optional.

Supported storage:

  • Memory storage, URI identifier is mem://

    After the identifier is a name to distinguish a particular memory storage location.

    For example, mem://foobar.

  • OS file system storage, URI identifier is file://

    After the identifier is the path to a directory on OS file system. It can be a relative or absolute path. Note that path is not same as an standard encoded URL.

    For example, file://./foo/bar or file://C:/Users/foo bar/dir.

    This storage must be enabled by Cargo feature storage-file.

  • SQLite storage, URI identifier is sqlite://

    After the identifier is the path to a SQLite database file. It can also be a in-memory SQLite database, that is, the path can be “:memory:”.

    For example, sqlite://./foobar.sqlite.

    This storage must be enabled by Cargo feature storage-sqlite.

  • Redis storage, URI identifier is redis://

    After the identifier is the path to a Redis instance. Unix socket is supported. The URI format is:

    redis://[+unix+][:<passwd>@]<hostname>[:port][/<db>]

    This storage must be enabled by Cargo feature storage-redis.

After a repository is opened, all of the other methods provided by ZboxFS will be thread-safe.

Your application should destroy the password as soon as possible after calling this method.

Errors

Open a memory based repository without enable create option will return an error.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.