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§
Required Methods§
Sourcefn map<'life0, 'async_trait, N>(
&'life0 self,
name: N,
expire: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Self::MapType>> + Send + 'async_trait>>
fn map<'life0, 'async_trait, N>( &'life0 self, name: N, expire: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Self::MapType>> + Send + 'async_trait>>
Creates or accesses a named map
Sourcefn map_remove<'life0, 'async_trait, K>(
&'life0 self,
name: K,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn map_remove<'life0, 'async_trait, K>( &'life0 self, name: K, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Removes an entire map
Sourcefn map_contains_key<'life0, 'async_trait, K>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
fn map_contains_key<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
Checks if a map exists
Sourcefn list<'life0, 'async_trait, V>(
&'life0 self,
name: V,
expire: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Self::ListType>> + Send + '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>>
Creates or accesses a named list
Sourcefn list_remove<'life0, 'async_trait, K>(
&'life0 self,
name: K,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn list_remove<'life0, 'async_trait, K>( &'life0 self, name: K, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Removes an entire list
Sourcefn list_contains_key<'life0, 'async_trait, K>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
fn list_contains_key<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
Checks if a list exists
Sourcefn insert<'life0, 'life1, 'async_trait, K, V>(
&'life0 self,
key: K,
val: &'life1 V,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '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>>
Inserts a key-value pair
Sourcefn get<'life0, 'async_trait, K, V>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
fn get<'life0, 'async_trait, K, V>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
Retrieves a value by key
Sourcefn remove<'life0, 'async_trait, K>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn remove<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Removes a key-value pair
Sourcefn batch_insert<'life0, 'async_trait, V>(
&'life0 self,
key_vals: Vec<(Vec<u8>, V)>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '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>>
Batch insert of multiple key-value pairs
Sourcefn 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 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
Sourcefn counter_incr<'life0, 'async_trait, K>(
&'life0 self,
key: K,
increment: isize,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn counter_incr<'life0, 'async_trait, K>( &'life0 self, key: K, increment: isize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Increments a counter value
Sourcefn counter_decr<'life0, 'async_trait, K>(
&'life0 self,
key: K,
increment: isize,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn counter_decr<'life0, 'async_trait, K>( &'life0 self, key: K, increment: isize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Decrements a counter value
Sourcefn counter_get<'life0, 'async_trait, K>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<Option<isize>>> + Send + 'async_trait>>
fn counter_get<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<isize>>> + Send + 'async_trait>>
Gets current counter value
Sourcefn counter_set<'life0, 'async_trait, K>(
&'life0 self,
key: K,
val: isize,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn counter_set<'life0, 'async_trait, K>( &'life0 self, key: K, val: isize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Sets counter to specific value
Sourcefn contains_key<'life0, 'async_trait, K>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
fn contains_key<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
Checks if key exists
Sourcefn len<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
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,
Gets number of items in storage (requires “len” feature)
Sourcefn 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 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
Sourcefn expire_at<'life0, 'async_trait, K>(
&'life0 self,
key: K,
at: i64,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + '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>>
Sets expiration timestamp for a key (requires “ttl” feature)
Sourcefn expire<'life0, 'async_trait, K>(
&'life0 self,
key: K,
dur: i64,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
fn expire<'life0, 'async_trait, K>( &'life0 self, key: K, dur: i64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
Sets expiration duration for a key (requires “ttl” feature)
Sourcefn ttl<'life0, 'async_trait, K>(
&'life0 self,
key: K,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>>> + Send + 'async_trait>>
fn ttl<'life0, 'async_trait, K>( &'life0 self, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<i64>>> + Send + 'async_trait>>
Gets remaining time-to-live for a key (requires “ttl” feature)
Sourcefn 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 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
Sourcefn 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 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
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.