[−][src]Struct starling::hash_tree::HashTree
A MerkleBIT
implemented with a HashMap
. Can be used for quickly storing items in memory, though
larger sets of items should be stored on disk or over the network in a real database.
Methods
impl<ValueType, ArrayType> HashTree<ArrayType, ValueType> where
ValueType: Encode + Decode,
ArrayType: Array,
[src]
ValueType: Encode + Decode,
ArrayType: Array,
pub fn new(depth: usize) -> BinaryMerkleTreeResult<Self>
[src]
pub fn open(path: &PathBuf, depth: usize) -> BinaryMerkleTreeResult<Self>
[src]
Creates a new HashTree
. This method exists for conforming with the general API for the MerkleBIT
and does not need to be used (except for compatibility). Prefer new
when possible.
Errors
None.
pub fn get(
&self,
root_hash: &ArrayType,
keys: &mut [ArrayType]
) -> BinaryMerkleTreeResult<HashMap<ArrayType, Option<ValueType>>>
[src]
&self,
root_hash: &ArrayType,
keys: &mut [ArrayType]
) -> BinaryMerkleTreeResult<HashMap<ArrayType, Option<ValueType>>>
Gets the values associated with keys
from the tree.
Errors
Exception
generated if the get
encounters an invalid state during tree traversal.
pub fn insert(
&mut self,
previous_root: Option<&ArrayType>,
keys: &mut [ArrayType],
values: &[ValueType]
) -> BinaryMerkleTreeResult<ArrayType>
[src]
&mut self,
previous_root: Option<&ArrayType>,
keys: &mut [ArrayType],
values: &[ValueType]
) -> BinaryMerkleTreeResult<ArrayType>
Inserts elements into the tree. Using previous_root
specifies that the insert depends on
the state from the previous root, and will update references accordingly.
Errors
Exception
generated if the insert
encounters an invalid state during tree traversal.
pub fn remove(&mut self, root_hash: &ArrayType) -> BinaryMerkleTreeResult<()>
[src]
Removes a root from the tree. This will remove all elements with less than two references under the given root.
Errors
Exception
generated if the remove
encounters an invalid state during tree traversal.
pub fn generate_inclusion_proof(
&self,
root: &ArrayType,
key: ArrayType
) -> BinaryMerkleTreeResult<Vec<(ArrayType, bool)>>
[src]
&self,
root: &ArrayType,
key: ArrayType
) -> BinaryMerkleTreeResult<Vec<(ArrayType, bool)>>
Generates an inclusion proof for the given key at the specified root.
Errors
Exception
generated if an invalid state is encountered during tree traversal
pub fn verify_inclusion_proof(
root: &ArrayType,
key: ArrayType,
value: &ValueType,
proof: &[(ArrayType, bool)]
) -> BinaryMerkleTreeResult<()>
[src]
root: &ArrayType,
key: ArrayType,
value: &ValueType,
proof: &[(ArrayType, bool)]
) -> BinaryMerkleTreeResult<()>
Verifies an inclusion proof with the given root, key, and value.
Errors
Exception
generated if the given proof is invalid.
pub fn get_one(
&self,
root: &ArrayType,
key: &ArrayType
) -> BinaryMerkleTreeResult<Option<ValueType>>
[src]
&self,
root: &ArrayType,
key: &ArrayType
) -> BinaryMerkleTreeResult<Option<ValueType>>
Gets a single item out of the tree.
Errors
Exception
generated if the get_one
encounters an invalid state during tree traversal.
pub fn insert_one(
&mut self,
previous_root: Option<&ArrayType>,
key: &ArrayType,
value: &ValueType
) -> BinaryMerkleTreeResult<ArrayType>
[src]
&mut self,
previous_root: Option<&ArrayType>,
key: &ArrayType,
value: &ValueType
) -> BinaryMerkleTreeResult<ArrayType>
Inserts a single item into the tree.
Errors
Exception
generated if the insert_one
encounters an invalid state during tree traversal.
Auto Trait Implementations
impl<ArrayType, ValueType> RefUnwindSafe for HashTree<ArrayType, ValueType> where
ArrayType: RefUnwindSafe,
ValueType: RefUnwindSafe,
ArrayType: RefUnwindSafe,
ValueType: RefUnwindSafe,
impl<ArrayType, ValueType> Send for HashTree<ArrayType, ValueType> where
ArrayType: Send,
ValueType: Send,
ArrayType: Send,
ValueType: Send,
impl<ArrayType, ValueType> Sync for HashTree<ArrayType, ValueType> where
ArrayType: Sync,
ValueType: Sync,
ArrayType: Sync,
ValueType: Sync,
impl<ArrayType, ValueType> Unpin for HashTree<ArrayType, ValueType> where
ArrayType: Unpin,
ValueType: Unpin,
ArrayType: Unpin,
ValueType: Unpin,
impl<ArrayType, ValueType> UnwindSafe for HashTree<ArrayType, ValueType> where
ArrayType: UnwindSafe,
ValueType: UnwindSafe,
ArrayType: UnwindSafe,
ValueType: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,