Struct vertree::Tree [] [src]

pub struct Tree {
    pub root: Arc<Node>,
    pub depth: u32,
}

A hierarchical version tree.

This tree is persistent, and every update to a node both path copies the parent until it gets to the root and increments the parent's version number. Only a single thread can write to the tree at one time.

Fields

Methods

impl Tree
[src]

Create a new node of a given type

This function creates all intermediate directories that don't exist. It returns the new tree on success. Creation will fail if a directory component of the path matches an already existing leaf node or the leaf node component of path already exists.

This function is optimized for the successful case. It walks the tree from the root, copying on write or creating intermediate directory nodes as required until it gets to the leaf where it creates and inserts the new leaf node of the proper type. If there is an error, the new, partially path-copied tree is discarded as the root goes out of scope. This is an optimization on the successful path because it doesn't require traversing down the tree and then back upwards. It also doesn't require the use of parent pointers. Finally it doesn't rely on recursion, since Rust does not have tail recursion and we don't want to limit the depth of the tree arbitrarily.

Write a snapshot of a tree to the directory dir in MsgPack format.

The format of a filename is vertree_.tree Note that taking a snapshot of an identical tree will overwrite the previously written file. TODO: Do this in another thread.

Load a snapshot from the file at file

Perform a Compare and Swap operation with muliple compares and swaps

Every multi_cas consists of a Vec of Guards and a Vec of Operations. Each guard contains the path and version of a node in the tree. The versions must all be the same as the nodes in the tree for the operations to run. All operations must run successfully to return a Reply and the new tree. If either a guard or op fails, then an error is returned.

Some write operations, such as 'QueuePop' return values other than Ok. Due to this, we return an array of results on success.

Walk the tree until the desired node at path is found.

Return the content and its version or an error if any part of the path doesn't exist or the node at path is of the wrong type.

Trait Implementations

impl Debug for Tree
[src]

Formats the value using the given formatter.

impl Clone for Tree
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Eq for Tree
[src]

impl PartialEq for Tree
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Default for Tree
[src]

Returns the "default value" for a type. Read more