[−][src]Struct exonum_merkledb::indexes::ValueSetIndex
A set of value items.
ValueSetIndex
implements a set, storing an element as a value and using its hash as a key.
ValueSetIndex
requires that elements should implement the BinaryValue
trait.
Methods
impl<T, V> ValueSetIndex<T, V> where
T: RawAccess,
V: BinaryValue + ObjectHash,
[src]
T: RawAccess,
V: BinaryValue + ObjectHash,
pub fn contains(&self, item: &V) -> bool
[src]
Returns true
if the set contains the indicated value.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_value_set("name"); assert!(!index.contains(&1)); index.insert(1); assert!(index.contains(&1));
pub fn contains_by_hash(&self, hash: &Hash) -> bool
[src]
Returns true
if the set contains a value with the specified hash.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; use exonum_crypto; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_value_set("name"); let data = vec![1, 2, 3]; let data_hash = exonum_crypto::hash(&data); assert!(!index.contains_by_hash(&data_hash)); index.insert(data); assert!(index.contains_by_hash(&data_hash));
pub fn iter(&self) -> Entries<Hash, V>
[src]
Returns an iterator over set elements and their hashes. The elements are ordered as per lexicographic ordering of their hashes (i.e., effectively randomly).
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let index: ValueSetIndex<_, u8> = fork.get_value_set("name"); for val in index.iter() { println!("{:?}", val); }
pub fn hashes(&self) -> Keys<Hash>
[src]
Returns an iterator over hashes of set elements in ascending order.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let index: ValueSetIndex<_, u8> = fork.get_value_set("name"); for val in index.hashes() { println!("{:?}", val); }
pub fn iter_from(&self, from: &Hash) -> Entries<Hash, V>
[src]
Returns an iterator visiting all elements in arbitrary order starting from the specified hash of a value. Elements are yielded together with their hashes.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; use exonum_crypto::Hash; let db = TemporaryDB::new(); let fork = db.fork(); let index: ValueSetIndex<_, u8> = fork.get_value_set("name"); let hash = Hash::default(); for val in index.iter_from(&hash) { println!("{:?}", val); }
pub fn hashes_from(&self, from: &Hash) -> Keys<Hash>
[src]
Returns an iterator visiting hashes of all elements in ascending order starting from the specified hash.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; use exonum_crypto::Hash; let db = TemporaryDB::new(); let fork = db.fork(); let index: ValueSetIndex<_, u8> = fork.get_value_set("name"); let hash = Hash::default(); for val in index.hashes_from(&hash) { println!("{:?}", val); }
impl<T, V> ValueSetIndex<T, V> where
T: RawAccessMut,
V: BinaryValue + ObjectHash,
[src]
T: RawAccessMut,
V: BinaryValue + ObjectHash,
pub fn insert(&mut self, item: V)
[src]
Adds a value to the set.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_value_set("name"); index.insert(1); assert!(index.contains(&1));
pub fn remove(&mut self, item: &V)
[src]
Removes a value from the set.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_value_set("name"); index.insert(1); assert!(index.contains(&1)); index.remove(&1); assert!(!index.contains(&1));
pub fn remove_by_hash(&mut self, hash: &Hash)
[src]
Removes a value corresponding to the specified hash from the set.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; use exonum_crypto; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_value_set("name"); let data = vec![1, 2, 3]; let data_hash = exonum_crypto::hash(&data); index.insert(data); assert!(index.contains_by_hash(&data_hash)); index.remove_by_hash(&data_hash); assert!(!index.contains_by_hash(&data_hash));
pub fn clear(&mut self)
[src]
Clears the set, removing all values.
Notes
Currently, this method is not optimized to delete a large set of data. During the execution of this method, the amount of allocated memory is linearly dependent on the number of elements in the index.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, ValueSetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_value_set("name"); index.insert(1); assert!(index.contains(&1)); index.clear(); assert!(!index.contains(&1));
Trait Implementations
impl<T: Debug + RawAccess, V: Debug> Debug for ValueSetIndex<T, V>
[src]
impl<T, V> FromAccess<T> for ValueSetIndex<T::Base, V> where
T: Access,
V: BinaryValue + ObjectHash,
[src]
T: Access,
V: BinaryValue + ObjectHash,
fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]
fn from_root(access: T) -> Result<Self, AccessError>
[src]
impl<T, V> IndexIterator for ValueSetIndex<T, V> where
T: RawAccess,
V: BinaryValue + ObjectHash,
[src]
T: RawAccess,
V: BinaryValue + ObjectHash,
type Key = Hash
Type encompassing index keys.
type Value = V
Type encompassing index values.
fn index_iter(&self, from: Option<&Hash>) -> Entries<Hash, V>
[src]
impl<'a, T, V> IntoIterator for &'a ValueSetIndex<T, V> where
T: RawAccess,
V: BinaryValue + ObjectHash,
[src]
T: RawAccess,
V: BinaryValue + ObjectHash,
Auto Trait Implementations
impl<T, V> RefUnwindSafe for ValueSetIndex<T, V> where
T: RefUnwindSafe,
V: RefUnwindSafe,
<T as RawAccess>::Changes: RefUnwindSafe,
T: RefUnwindSafe,
V: RefUnwindSafe,
<T as RawAccess>::Changes: RefUnwindSafe,
impl<T, V> Send for ValueSetIndex<T, V> where
T: Send,
V: Send,
<T as RawAccess>::Changes: Send,
T: Send,
V: Send,
<T as RawAccess>::Changes: Send,
impl<T, V> Sync for ValueSetIndex<T, V> where
T: Sync,
V: Sync,
<T as RawAccess>::Changes: Sync,
T: Sync,
V: Sync,
<T as RawAccess>::Changes: Sync,
impl<T, V> Unpin for ValueSetIndex<T, V> where
T: Unpin,
V: Unpin,
<T as RawAccess>::Changes: Unpin,
T: Unpin,
V: Unpin,
<T as RawAccess>::Changes: Unpin,
impl<T, V> UnwindSafe for ValueSetIndex<T, V> where
T: UnwindSafe,
V: UnwindSafe,
<T as RawAccess>::Changes: UnwindSafe,
T: UnwindSafe,
V: UnwindSafe,
<T as RawAccess>::Changes: 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,