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> where
T: AsRef<Snapshot>,
[src]
T: AsRef<Snapshot>,
pub fn new<S: AsRef<str>>(name: S, index_type: IndexType, view: T) -> Self
[src]
Creates a new index representation based on the name and storage view.
Storage view can be specified as &Snapshot
or &mut Fork
. In the first case only
immutable methods are available. In the second case both immutable and mutable methods are
available.
pub fn with_prefix<S: AsRef<str>>(
name: S,
prefix: Vec<u8>,
index_type: IndexType,
view: T
) -> Self
[src]
name: S,
prefix: Vec<u8>,
index_type: IndexType,
view: T
) -> Self
Creates a new index representation based on the name, common prefix of its keys and storage view.
Storage view can be specified as &Snapshot
or &mut Fork
. In the first case only
immutable methods are available. In the second case both immutable and mutable methods are
available.
pub fn get<K: ?Sized, V>(&self, key: &K) -> Option<V> where
K: StorageKey,
V: StorageValue,
[src]
K: StorageKey,
V: StorageValue,
Returns a value of any type corresponding to the key of any type.
pub fn contains<K: ?Sized>(&self, key: &K) -> bool where
K: StorageKey,
[src]
K: StorageKey,
Returns true
if the index contains a value of any type for the specified key of
any type.
ⓘImportant traits for BaseIndexIter<'a, K, V>pub fn iter<P, K, V>(&self, subprefix: &P) -> BaseIndexIter<K, V> where
P: StorageKey,
K: StorageKey,
V: StorageValue,
[src]
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.
ⓘImportant traits for BaseIndexIter<'a, K, V>pub fn iter_from<P, F: ?Sized, K, V>(
&self,
subprefix: &P,
from: &F
) -> BaseIndexIter<K, V> where
P: StorageKey,
F: StorageKey,
K: StorageKey,
V: StorageValue,
[src]
&self,
subprefix: &P,
from: &F
) -> BaseIndexIter<K, V> where
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]
pub fn put<K, V>(&mut self, key: &K, value: V) where
K: StorageKey,
V: StorageValue,
[src]
K: StorageKey,
V: StorageValue,
Inserts the key-value pair into the index. Both key and value may be of any types.
pub fn remove<K: ?Sized>(&mut self, key: &K) where
K: StorageKey,
[src]
K: StorageKey,
Removes the key of any type from the index.
pub fn clear(&mut self)
[src]
Clears the index, removing entries with keys that starts with a prefix or all entries
if prefix
is None
.
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.