pub struct Infinitree<I, CustomData = ()> where
    CustomData: Serialize + DeserializeOwned + Send + Sync + 'static, 
{ /* private fields */ }
Expand description

An Infinitree root.

This is primarily a wrapper around an Index that manages versioning and key management.

Implementations

Initialize an empty index and tree with no version history.

Examples
use infinitree::{*, crypto::UsernamePassword, fields::Serialized, backends::Directory};

#[derive(Index, Default)]
struct Measurements {
    list: Serialized<Vec<usize>>
}

let mut tree = Infinitree::<Measurements>::empty(
    Directory::new("/storage").unwrap(),
    UsernamePassword::with_credentials("username".to_string(),
                                       "password".to_string()).unwrap()
).unwrap();

Load all version information from the tree.

This method doesn’t load the index, only the associated metadata.

Create a commit if there are changes in the index.

This persists currently in-memory data, and also records the commit with message to the log.

Examples

Any commit message works that implements ToString.

use infinitree::{*, crypto::UsernamePassword, fields::Serialized, backends::Directory};

let mut tree = Infinitree::<infinitree::fields::VersionedMap<String, String>>::empty(
    Directory::new("/storage").unwrap(),
    UsernamePassword::with_credentials("username".to_string(), "password".to_string()).unwrap()
).unwrap();

// Commit message can be omitted using `None`
tree.commit(None);

// Otherwise a hardcoded &str also works
tree.commit("this is a message");

// Or even a String instance
let message = "this is a string".to_string();
tree.commit(message);

Wraps the given index in an Infinitree.

This is primarily useful if you’re done writing an Index, and want to commit and persist it, or if you need extra initialization because Default is not viable.

Change the current wrapping key and immediately commit to the backend.

Will return an error if the operation is not supported by either the new or the old key.

Return all generations in the tree.

Only run persistence query operations (query, load, iter) on the selected generations.

Commit changes currently in the index.

For full documentation, please read Infinitree::commit.

Commit using manually prepared metadata

For full documentation, please read Infinitree::commit.

Return a handle for an object writer.

This can be used to manually write sparse data if you don’t want to store it in memory. Especially useful for e.g. files.

Note that currently there’s no fragmenting internally, so anything written using an ObjectWriter must be less than about 4MB.

Return a handle for an object reader

The object reader is for reading out those ChunkPointers that you get when using an AEADWriter stack manually.

You can obtain an AEADWriter using object_writer.

Get a hasher that produces hashes only usable with this stash’s keys

This internally is a keyed Blake3 instance.

Load into memory all fields for the selected version ranges

Load the field for the selected generation set

Load into memory all data from field where pred returns true

Same as query, but returns an Iterator

Return an immutable reference to the internal index.

By design this is read-only, as the index fields should use internal mutability and be thread-safe individually.

Return the backend

This allows synchronization of backends that queue upload jobs, or other background tasks.

Returns the number of index objects

Trait Implementations

Executes the destructor for this 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

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.