Trait litemap::store::Store

source ·
pub trait Store<K: ?Sized, V: ?Sized>: Sized {
    // Required methods
    fn lm_len(&self) -> usize;
    fn lm_get(&self, index: usize) -> Option<(&K, &V)>;
    fn lm_binary_search_by<F>(&self, cmp: F) -> Result<usize, usize>
       where F: FnMut(&K) -> Ordering;

    // Provided methods
    fn lm_is_empty(&self) -> bool { ... }
    fn lm_last(&self) -> Option<(&K, &V)> { ... }
}
Expand description

Trait to enable pluggable backends for LiteMap.

Some methods have default implementations provided for convenience; however, it is generally better to implement all methods that your data store supports.

Required Methods§

source

fn lm_len(&self) -> usize

Returns the number of elements in the store.

source

fn lm_get(&self, index: usize) -> Option<(&K, &V)>

Gets a key/value pair at the specified index.

source

fn lm_binary_search_by<F>(&self, cmp: F) -> Result<usize, usize>
where F: FnMut(&K) -> Ordering,

Searches the store for a particular element with a comparator function.

See the binary search implementation on slice for more information.

Provided Methods§

source

fn lm_is_empty(&self) -> bool

Returns whether the store is empty (contains 0 elements).

source

fn lm_last(&self) -> Option<(&K, &V)>

Gets the last element in the store, or None if the store is empty.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, K: 'a, V: 'a> Store<K, V> for &'a [(K, V)]

source§

fn lm_len(&self) -> usize

source§

fn lm_is_empty(&self) -> bool

source§

fn lm_get(&self, index: usize) -> Option<(&K, &V)>

source§

fn lm_last(&self) -> Option<(&K, &V)>

source§

fn lm_binary_search_by<F>(&self, cmp: F) -> Result<usize, usize>
where F: FnMut(&K) -> Ordering,

source§

impl<K, V> Store<K, V> for Vec<(K, V)>

source§

fn lm_len(&self) -> usize

source§

fn lm_is_empty(&self) -> bool

source§

fn lm_get(&self, index: usize) -> Option<(&K, &V)>

source§

fn lm_last(&self) -> Option<(&K, &V)>

source§

fn lm_binary_search_by<F>(&self, cmp: F) -> Result<usize, usize>
where F: FnMut(&K) -> Ordering,

Implementors§