litemap::store

Trait 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.

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.

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§