[][src]Struct zbox::RepoOpener

pub struct RepoOpener { /* fields omitted */ }

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

Methods

impl RepoOpener[src]

pub fn new() -> Self[src]

Creates a blank new set of options ready for configuration.

pub fn ops_limit(&mut self, ops_limit: OpsLimit) -> &mut Self[src]

Sets the password hash operation limit.

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

pub fn mem_limit(&mut self, mem_limit: MemLimit) -> &mut Self[src]

Sets the password hash memory limit.

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

pub fn cipher(&mut self, cipher: Cipher) -> &mut Self[src]

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.

pub fn create(&mut self, create: bool) -> &mut Self[src]

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.

pub fn create_new(&mut self, create_new: bool) -> &mut Self[src]

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.

pub fn compress(&mut self, compress: bool) -> &mut Self[src]

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.

pub fn version_limit(&mut self, version_limit: u8) -> &mut Self[src]

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.

pub fn dedup_chunk(&mut self, dedup_chunk: bool) -> &mut Self[src]

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.

pub fn dedup_file(&mut self, dedup_file: bool) -> &mut Self[src]

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.

pub fn read_only(&mut self, read_only: bool) -> &mut Self[src]

Sets the option for read-only mode.

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

pub fn force(&mut self, force: bool) -> &mut Self[src]

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.

pub fn open(&self, uri: &str, pwd: &str) -> Result<Repo>[src]

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

impl Clone for RepoOpener[src]

impl Debug for RepoOpener[src]

impl Default for RepoOpener[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.