Unordered

Trait Unordered 

Source
pub trait Unordered: Send + Sync {
    type Value: Eq + Send + Sync;
    type Cursor<'a>: Cursor<Value = Self::Value>
       where Self: 'a;

    // Required methods
    fn get<'a>(
        &'a self,
        key: &[u8],
    ) -> impl Iterator<Item = &'a Self::Value> + Send + 'a
       where Self::Value: 'a;
    fn get_mut<'a>(&'a mut self, key: &[u8]) -> Option<Self::Cursor<'a>>;
    fn get_mut_or_insert<'a>(
        &'a mut self,
        key: &[u8],
        value: Self::Value,
    ) -> Option<Self::Cursor<'a>>;
    fn insert(&mut self, key: &[u8], value: Self::Value);
    fn insert_and_prune(
        &mut self,
        key: &[u8],
        value: Self::Value,
        predicate: impl Fn(&Self::Value) -> bool,
    );
    fn prune(&mut self, key: &[u8], predicate: impl Fn(&Self::Value) -> bool);
    fn remove(&mut self, key: &[u8]);
}
Expand description

A trait defining the operations provided by a memory-efficient index that maps translated keys to arbitrary values, with no ordering assumed over the key space.

Required Associated Types§

Source

type Value: Eq + Send + Sync

The type of values the index stores.

Source

type Cursor<'a>: Cursor<Value = Self::Value> where Self: 'a

The type of cursor returned by this index to iterate over values with conflicting keys.

Required Methods§

Source

fn get<'a>( &'a self, key: &[u8], ) -> impl Iterator<Item = &'a Self::Value> + Send + 'a
where Self::Value: 'a,

Returns an iterator over all values associated with a translated key.

Source

fn get_mut<'a>(&'a mut self, key: &[u8]) -> Option<Self::Cursor<'a>>

Provides mutable access to the values associated with a translated key, if the key exists.

Source

fn get_mut_or_insert<'a>( &'a mut self, key: &[u8], value: Self::Value, ) -> Option<Self::Cursor<'a>>

Provides mutable access to the values associated with a translated key (if the key exists), otherwise inserts a new value and returns None.

Source

fn insert(&mut self, key: &[u8], value: Self::Value)

Inserts a new value at the current position.

Source

fn insert_and_prune( &mut self, key: &[u8], value: Self::Value, predicate: impl Fn(&Self::Value) -> bool, )

Insert a value at the given translated key, and prune any values that are no longer valid.

If the value is prunable, it will not be inserted.

Source

fn prune(&mut self, key: &[u8], predicate: impl Fn(&Self::Value) -> bool)

Remove all values associated with a translated key that match predicate.

Source

fn remove(&mut self, key: &[u8])

Remove all values associated with a translated key.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Translator, V: Eq + Send + Sync> Unordered for commonware_storage::index::ordered::Index<T, V>

Source§

type Value = V

Source§

type Cursor<'a> = Cursor<'a, <T as Translator>::Key, V> where Self: 'a

Source§

impl<T: Translator, V: Eq + Send + Sync> Unordered for commonware_storage::index::unordered::Index<T, V>

Source§

type Value = V

Source§

type Cursor<'a> = Cursor<'a, <T as Translator>::Key, V> where Self: 'a

Source§

impl<T: Translator, V: Eq + Send + Sync, const P: usize> Unordered for commonware_storage::index::partitioned::ordered::Index<T, V, P>

Source§

type Value = V

Source§

type Cursor<'a> = <Index<T, V> as Unordered>::Cursor<'a> where Self: 'a

Source§

impl<T: Translator, V: Eq + Send + Sync, const P: usize> Unordered for commonware_storage::index::partitioned::unordered::Index<T, V, P>

Source§

type Value = V

Source§

type Cursor<'a> = <Index<T, V> as Unordered>::Cursor<'a> where Self: 'a