Ordered

Trait Ordered 

Source
pub trait Ordered:
    Unordered
    + Send
    + Sync {
    type Iterator<'a>: Iterator<Item = &'a Self::Value> + Send
       where Self: 'a;

    // Required methods
    fn prev_translated_key<'a>(
        &'a self,
        key: &[u8],
    ) -> Option<(Self::Iterator<'a>, bool)>
       where Self::Value: 'a;
    fn next_translated_key<'a>(
        &'a self,
        key: &[u8],
    ) -> Option<(Self::Iterator<'a>, bool)>
       where Self::Value: 'a;
    fn first_translated_key<'a>(&'a self) -> Option<Self::Iterator<'a>>
       where Self::Value: 'a;
    fn last_translated_key<'a>(&'a self) -> Option<Self::Iterator<'a>>
       where Self::Value: 'a;
}
Expand description

A trait defining the additional operations provided by a memory-efficient index that allows ordered traversal of the indexed keys.

Required Associated Types§

Source

type Iterator<'a>: Iterator<Item = &'a Self::Value> + Send where Self: 'a

Required Methods§

Source

fn prev_translated_key<'a>( &'a self, key: &[u8], ) -> Option<(Self::Iterator<'a>, bool)>
where Self::Value: 'a,

Source

fn next_translated_key<'a>( &'a self, key: &[u8], ) -> Option<(Self::Iterator<'a>, bool)>
where Self::Value: 'a,

For example, if the translator is looking only at the first byte of a key, and the index contains values for translated keys 0b, 1c, and 2d, then get_next([0b, 01, 02, ...]) would return the values associated with 1c, get_next([2a, 01, 02, ...]) would return the values associated with 2d, and get_next([2d]) would “cycle around” to the values associated with 0b, returning true for the bool. Because values associated with the same translated key can appear in any order, keys with the same first byte in this example would need to be ordered by the caller if a full ordering over the untranslated keyspace is desired.

Source

fn first_translated_key<'a>(&'a self) -> Option<Self::Iterator<'a>>
where Self::Value: 'a,

Source

fn last_translated_key<'a>(&'a self) -> Option<Self::Iterator<'a>>
where Self::Value: 'a,

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> Ordered for commonware_storage::index::ordered::Index<T, V>

Source§

type Iterator<'a> = ImmutableCursor<'a, V> where Self: 'a

Source§

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

Source§

type Iterator<'a> = <Index<T, V> as Ordered>::Iterator<'a> where Self: 'a