Trait StorageDB

Source
pub trait StorageDB: Send + Sync {
    type MapType: Map;
    type ListType: List;

Show 25 methods // Required methods fn map<'life0, 'async_trait, N>( &'life0 self, name: N, expire: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Self::MapType>> + Send + 'async_trait>> where N: 'async_trait + AsRef<[u8]> + Sync + Send, Self: 'async_trait, 'life0: 'async_trait; fn map_remove<'life0, 'async_trait, K>( &'life0 self, name: 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 map_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 list<'life0, 'async_trait, V>( &'life0 self, name: V, expire: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Self::ListType>> + Send + 'async_trait>> where V: 'async_trait + AsRef<[u8]> + Sync + Send, Self: 'async_trait, 'life0: 'async_trait; fn list_remove<'life0, 'async_trait, K>( &'life0 self, name: 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 list_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 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 + '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 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 counter_incr<'life0, 'async_trait, K>( &'life0 self, key: K, increment: isize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn counter_decr<'life0, 'async_trait, K>( &'life0 self, key: K, increment: isize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn counter_get<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<isize>>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn counter_set<'life0, 'async_trait, K>( &'life0 self, key: K, val: isize, ) -> 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 db_size<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn expire_at<'life0, 'async_trait, K>( &'life0 self, key: K, at: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn expire<'life0, 'async_trait, K>( &'life0 self, key: K, dur: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn ttl<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<i64>>> + Send + 'async_trait>> where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn map_iter<'a, 'async_trait>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<StorageMap>> + Send + 'a>>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait; fn list_iter<'a, 'async_trait>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<StorageList>> + Send + 'a>>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait; fn scan<'a, 'async_trait, P>( &'a mut self, pattern: P, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncIterator<Item = Result<Vec<u8>>> + Send + 'a>>> + Send + 'async_trait>> where P: AsRef<[u8]> + Send + Sync + 'async_trait, Self: 'async_trait, 'a: 'async_trait; fn info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Core storage database operations

Required Associated Types§

Source

type MapType: Map

Concrete Map type for this storage

Source

type ListType: List

Concrete List type for this storage

Required Methods§

Source

fn map<'life0, 'async_trait, N>( &'life0 self, name: N, expire: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Self::MapType>> + Send + 'async_trait>>
where N: 'async_trait + AsRef<[u8]> + Sync + Send, Self: 'async_trait, 'life0: 'async_trait,

Creates or accesses a named map

Source

fn map_remove<'life0, 'async_trait, K>( &'life0 self, name: 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 an entire map

Source

fn map_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 a map exists

Source

fn list<'life0, 'async_trait, V>( &'life0 self, name: V, expire: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Self::ListType>> + Send + 'async_trait>>
where V: 'async_trait + AsRef<[u8]> + Sync + Send, Self: 'async_trait, 'life0: 'async_trait,

Creates or accesses a named list

Source

fn list_remove<'life0, 'async_trait, K>( &'life0 self, name: 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 an entire list

Source

fn list_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 a list exists

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 + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inserts a key-value pair

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 by key

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-value pair

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 multiple 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 counter_incr<'life0, 'async_trait, K>( &'life0 self, key: K, increment: isize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where K: AsRef<[u8]> + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Increments a counter value

Source

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

Decrements a counter value

Source

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

Gets current counter value

Source

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

Sets counter to specific value

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

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 storage (requires “len” feature)

Source

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

Gets total storage size in bytes

Source

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

Sets expiration timestamp for a key (requires “ttl” feature)

Source

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

Sets expiration duration for a key (requires “ttl” feature)

Source

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

Gets remaining time-to-live for a key (requires “ttl” feature)

Source

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

Iterates over all maps in storage

Source

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

Iterates over all lists in storage

Source

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

Scans keys matching pattern (supports * and ? wildcards)

Source

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

Gets storage backend information

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 StorageDB for rmqtt_storage::RedisClusterStorageDB

Source§

type MapType = RedisStorageMap

Source§

type ListType = RedisStorageList

Source§

impl StorageDB for rmqtt_storage::RedisStorageDB

Source§

type MapType = RedisStorageMap

Source§

type ListType = RedisStorageList

Source§

impl StorageDB for SledStorageDB

Source§

type MapType = SledStorageMap

Source§

type ListType = SledStorageList