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
root: Arc<Node>
depth: u32
Methods
impl Tree
[src]
fn new() -> Tree
fn create(&self, path: &str, ty: NodeType) -> Result<Tree>
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.
fn delete(&self, path: &str) -> Result<(u64, Tree)>
fn keys(&self) -> Vec<(String, u64)>
fn iter(&self) -> Iter
fn path_iter<'a>(&'a self, paths: Vec<&'a str>) -> PathIter<'a>
fn snapshot(&self, dir: &str) -> Result<String>
Write a snapshot of a tree to the directory dir
in MsgPack format.
The format of a filename is vertree_
fn load_snapshot(path: &str) -> Result<Tree>
Load a snapshot from the file at file
fn multi_cas(
&self,
guards: Vec<Guard>,
ops: Vec<WriteOp>
) -> Result<(Vec<Reply>, Tree)>
&self,
guards: Vec<Guard>,
ops: Vec<WriteOp>
) -> Result<(Vec<Reply>, Tree)>
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.
fn blob_put(&self, path: String, val: Vec<u8>) -> Result<(Reply, Tree)>
fn queue_push(&self, path: String, val: Vec<u8>) -> Result<(Reply, Tree)>
fn queue_pop(&self, path: String) -> Result<(Reply, Tree)>
fn set_insert(&self, path: String, val: Vec<u8>) -> Result<(Reply, Tree)>
fn set_remove(&self, path: String, val: Vec<u8>) -> Result<(Reply, Tree)>
fn blob_get(&self, path: String) -> Result<Reply>
fn blob_size(&self, path: String) -> Result<Reply>
fn queue_front(&self, path: String) -> Result<Reply>
fn queue_back(&self, path: String) -> Result<Reply>
fn queue_len(&self, path: String) -> Result<Reply>
fn set_contains(&self, path: String, val: Vec<u8>) -> Result<Reply>
fn set_subset(
&self,
path1: String,
path2: Option<String>,
set: Option<HashSet<Vec<u8>>>
) -> Result<Reply>
&self,
path1: String,
path2: Option<String>,
set: Option<HashSet<Vec<u8>>>
) -> Result<Reply>
fn set_superset(
&self,
path1: String,
path2: Option<String>,
set: Option<HashSet<Vec<u8>>>
) -> Result<Reply>
&self,
path1: String,
path2: Option<String>,
set: Option<HashSet<Vec<u8>>>
) -> Result<Reply>
fn set_union(
&self,
paths: Vec<String>,
sets: Vec<HashSet<Vec<u8>>>
) -> Result<Reply>
&self,
paths: Vec<String>,
sets: Vec<HashSet<Vec<u8>>>
) -> Result<Reply>
fn set_intersection(&self, path1: &str, path2: &str) -> Result<Reply>
fn set_difference(&self, path1: &str, path2: &str) -> Result<Reply>
fn set_symmetric_difference(&self, path1: &str, path2: &str) -> Result<Reply>
fn find(&self, path: &str, ty: NodeType) -> Result<(&Content, u64)>
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]
impl Clone for Tree
[src]
fn clone(&self) -> Tree
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Eq for Tree
[src]
impl PartialEq for Tree
[src]
fn eq(&self, __arg_0: &Tree) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Tree) -> bool
This method tests for !=
.