Struct exonum::storage::base_index::BaseIndex
[−]
[src]
pub struct BaseIndex<T> { /* fields omitted */ }
Basic struct for all indices that implements common features.
This structure is not intended for direct use, rather it is the basis for building other types of indices.
BaseIndex
requires that the keys implement the StorageKey
trait and the values implement
StorageValue
trait. However, this structure is not bound to specific types and allows the
use of any types as keys or values.
Methods
impl<T> BaseIndex<T>
[src]
impl<T> BaseIndex<T> where
T: AsRef<Snapshot>,
[src]
T: AsRef<Snapshot>,
fn get<K, V>(&self, key: &K) -> Option<V> where
K: StorageKey,
V: StorageValue,
K: StorageKey,
V: StorageValue,
Returns a value of any type corresponding to the key of any type.
fn contains<K>(&self, key: &K) -> bool where
K: StorageKey,
K: StorageKey,
Returns true
if the index contains a value of any type for the specified key of
any type.
fn iter<P, K, V>(&self, subprefix: &P) -> BaseIndexIter<K, V> where
P: StorageKey,
K: StorageKey,
V: StorageValue,
P: StorageKey,
K: StorageKey,
V: StorageValue,
Returns an iterator over the entries of the index in ascending order. The iterator element
type is any key-value pair. An argument subprefix
allows to specify a subset of keys
for iteration.
fn iter_from<P, F, K, V>(&self, subprefix: &P, from: &F) -> BaseIndexIter<K, V> where
P: StorageKey,
F: StorageKey,
K: StorageKey,
V: StorageValue,
P: StorageKey,
F: StorageKey,
K: StorageKey,
V: StorageValue,
Returns an iterator over the entries of the index in ascending order starting from the
specified key. The iterator element type is any key-value pair. An argument subprefix
allows to specify a subset of iteration.
impl<'a> BaseIndex<&'a mut Fork>
[src]
fn put<K, V>(&mut self, key: &K, value: V) where
K: StorageKey,
V: StorageValue,
K: StorageKey,
V: StorageValue,
Inserts the key-value pair into the index. Both key and value may be of any types.
fn remove<K>(&mut self, key: &K) where
K: StorageKey,
K: StorageKey,
Removes the key of any type from the index.
fn clear(&mut self)
Clears the index, removing all entries.
Notes
Currently this method is not optimized to delete 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.