Skip to main content

IndexBackend

Trait IndexBackend 

Source
pub trait IndexBackend<K: Clone + Eq + Hash, V: Clone>: Send + Sync {
    // Required methods
    fn size(&self) -> usize;
    fn has(&self, primary: &K) -> bool;
    fn get(&self, primary: &K) -> Option<V>;
    fn get_row(&self, primary: &K) -> Option<IndexRow<K, V>>;
    fn upsert(&mut self, primary: K, secondary: String, value: V) -> bool;
    fn upsert_many(&mut self, rows: Vec<(K, String, V)>) -> usize;
    fn delete(&mut self, primary: &K) -> bool;
    fn delete_many(&mut self, primaries: &[K]) -> usize;
    fn clear(&mut self) -> usize;
    fn to_ordered(&self) -> Vec<IndexRow<K, V>>;
    fn to_primary_map(&self) -> Vec<(K, V)>;
}
Expand description

Storage backend for crate::ReactiveIndex.

Required Methods§

Source

fn size(&self) -> usize

Source

fn has(&self, primary: &K) -> bool

Source

fn get(&self, primary: &K) -> Option<V>

Source

fn get_row(&self, primary: &K) -> Option<IndexRow<K, V>>

Get the full row (primary + secondary + value) by primary key.

Source

fn upsert(&mut self, primary: K, secondary: String, value: V) -> bool

Returns true if inserted (new key), false if updated.

Source

fn upsert_many(&mut self, rows: Vec<(K, String, V)>) -> usize

Source

fn delete(&mut self, primary: &K) -> bool

Source

fn delete_many(&mut self, primaries: &[K]) -> usize

Source

fn clear(&mut self) -> usize

Source

fn to_ordered(&self) -> Vec<IndexRow<K, V>>

Source

fn to_primary_map(&self) -> Vec<(K, V)>

Implementors§

Source§

impl<K: Clone + Eq + Hash + Send + Sync + ToString, V: Clone + Send + Sync> IndexBackend<K, V> for VecIndexBackend<K, V>