Trait AoraMap

Source
pub trait AoraMap<K, V, const KEY_LEN: usize = 32>
where K: Into<[u8; KEY_LEN]> + From<[u8; KEY_LEN]>,
{ // Required methods fn contains_key(&self, key: K) -> bool; fn get(&self, key: K) -> Option<V>; fn insert(&mut self, key: K, item: &V); fn iter(&self) -> impl Iterator<Item = (K, V)>; // Provided methods fn get_expect(&self, key: K) -> V { ... } fn extend<'a>(&mut self, iter: impl IntoIterator<Item = (K, &'a V)>) where V: 'a { ... } }
Expand description

Trait for providers of append-only key-value maps.

Required Methods§

Source

fn contains_key(&self, key: K) -> bool

Checks whether a given value is present in the log.

Source

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

Retrieves value from the log.

§Panics

Panics if the item under the provided key is not present.

Source

fn insert(&mut self, key: K, item: &V)

Inserts (appends) an item to the append-only log. If the item is already in the log, does noting.

§Panic

Panics if the item under the given id is different from another item under the same id already present in the log.

Source

fn iter(&self) -> impl Iterator<Item = (K, V)>

Returns an iterator over the key and value pairs.

Provided Methods§

Source

fn get_expect(&self, key: K) -> V

Retrieves value from the log.

§Panics

Panics if the item under the provided key is not present.

Source

fn extend<'a>(&mut self, iter: impl IntoIterator<Item = (K, &'a V)>)
where V: 'a,

Inserts (appends) all items from an iterator to the append-only log.

§Panic

Panics if any of the items is different from an item under the same id already present in the log.

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<K, V, const MAGIC: u64, const VER: u16, const KEY_LEN: usize> AoraMap<K, V, KEY_LEN> for FileAoraMap<K, V, MAGIC, VER, KEY_LEN>
where K: Into<[u8; KEY_LEN]> + From<[u8; KEY_LEN]>, V: Eq + StrictEncode + StrictDecode,

Available on crate feature file-strict only.