Trait Map

Source
pub trait Map: Sync + Send {
Show 18 methods // Required methods fn name(&self) -> &[u8] ; fn insert<'life0, 'life1, 'async_trait, K, V>( &'life0 self, key: K, val: &'life1 V, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, V: Serialize + Sync + Send + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get<'life0, 'async_trait, K, V>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, V: DeserializeOwned + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn remove<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn contains_key<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where K: 'async_trait + AsRef<[u8]> + Sync + Send, Self: 'async_trait, 'life0: 'async_trait; fn len<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn is_empty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_and_fetch<'life0, 'async_trait, K, V>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, V: DeserializeOwned + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn remove_with_prefix<'life0, 'async_trait, K>( &'life0 self, prefix: K, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn batch_insert<'life0, 'async_trait, V>( &'life0 self, key_vals: Vec<(Vec<u8>, V)>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where V: Serialize + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn batch_remove<'life0, 'async_trait>( &'life0 self, keys: Vec<Vec<u8>>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn iter<'a, 'async_trait, V>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<(Vec<u8>, V)>> + Send + 'a>>> + Send + 'async_trait>> where V: DeserializeOwned + Sync + Send + 'a + 'static + 'async_trait, Self: 'async_trait, 'a: 'async_trait; fn key_iter<'a, 'async_trait>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<Vec<u8>>> + Send + 'a>>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait; fn prefix_iter<'a, 'async_trait, P, V>( &'a mut self, prefix: P, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<(Vec<u8>, V)>> + Send + 'a>>> + Send + 'async_trait>> where P: AsRef<[u8]> + Send + Sync + 'async_trait, V: DeserializeOwned + Sync + Send + 'a + 'static + 'async_trait, Self: 'async_trait, 'a: 'async_trait; fn expire_at<'life0, 'async_trait>( &'life0 self, at: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn expire<'life0, 'async_trait>( &'life0 self, dur: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn ttl<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<i64>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Map (dictionary) storage operations

Required Methods§

Source

fn name(&self) -> &[u8]

Gets the name of this map

Source

fn insert<'life0, 'life1, 'async_trait, K, V>( &'life0 self, key: K, val: &'life1 V, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where K: AsRef<[u8]> + Sync + Send + 'async_trait, V: Serialize + Sync + Send + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inserts a key-value pair into the map

Source

fn get<'life0, 'async_trait, K, V>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
where K: AsRef<[u8]> + Sync + Send + 'async_trait, V: DeserializeOwned + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Retrieves a value from the map

Source

fn remove<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Removes a key from the map

Source

fn contains_key<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where K: 'async_trait + AsRef<[u8]> + Sync + Send, Self: 'async_trait, 'life0: 'async_trait,

Checks if key exists in the map

Source

fn len<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets number of items in map (requires “map_len” feature)

Source

fn is_empty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks if map is empty

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clears all entries in the map

Source

fn remove_and_fetch<'life0, 'async_trait, K, V>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
where K: AsRef<[u8]> + Sync + Send + 'async_trait, V: DeserializeOwned + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Removes a key and returns its value

Source

fn remove_with_prefix<'life0, 'async_trait, K>( &'life0 self, prefix: K, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Removes all keys with given prefix

Source

fn batch_insert<'life0, 'async_trait, V>( &'life0 self, key_vals: Vec<(Vec<u8>, V)>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where V: Serialize + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Batch insert of key-value pairs

Source

fn batch_remove<'life0, 'async_trait>( &'life0 self, keys: Vec<Vec<u8>>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Batch removal of keys

Source

fn iter<'a, 'async_trait, V>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<(Vec<u8>, V)>> + Send + 'a>>> + Send + 'async_trait>>
where V: DeserializeOwned + Sync + Send + 'a + 'static + 'async_trait, Self: 'async_trait, 'a: 'async_trait,

Iterates over all key-value pairs

Source

fn key_iter<'a, 'async_trait>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<Vec<u8>>> + Send + 'a>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Iterates over all keys

Source

fn prefix_iter<'a, 'async_trait, P, V>( &'a mut self, prefix: P, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<(Vec<u8>, V)>> + Send + 'a>>> + Send + 'async_trait>>
where P: AsRef<[u8]> + Send + Sync + 'async_trait, V: DeserializeOwned + Sync + Send + 'a + 'static + 'async_trait, Self: 'async_trait, 'a: 'async_trait,

Iterates over key-value pairs with given prefix

Source

fn expire_at<'life0, 'async_trait>( &'life0 self, at: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets expiration timestamp for the entire map (requires “ttl” feature)

Source

fn expire<'life0, 'async_trait>( &'life0 self, dur: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets expiration duration for the entire map (requires “ttl” feature)

Source

fn ttl<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<i64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets remaining time-to-live for the map (requires “ttl” feature)

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§