Skip to main content

Storage

Trait Storage 

Source
pub trait Storage:
    Send
    + Sync
    + Debug {
Show 28 methods // Required methods fn backend(&self) -> StorageBackend; fn metadata<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageMetadata>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageHealth>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageStats>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn insert<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + Serialize + DeserializeOwned + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn insert_with_ttl<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ttl_seconds: i64, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn get<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Option<StorageEntry<T>>>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn update<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn update_versioned<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, expected_version: u64, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn delete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, table: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn exists<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, table: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn execute_batch<'life0, 'async_trait>( &'life0 self, batch: Batch, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn query<'life0, 'async_trait, T>( &'life0 self, query: Query, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static, 'life0: 'async_trait; fn count<'life0, 'async_trait>( &'life0 self, query: Query, ) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn begin_transaction<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<Transaction>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn commit_transaction<'life0, 'async_trait>( &'life0 self, transaction: Transaction, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn rollback_transaction<'life0, 'async_trait>( &'life0 self, transaction: Transaction, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn scan_prefix<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, table: &'life1 str, prefix: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<String>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_multi<'life0, 'life1, 'async_trait, T>( &'life0 self, table: &'life1 str, keys: Vec<String>, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Option<StorageEntry<T>>>>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_multi<'life0, 'life1, 'async_trait>( &'life0 self, table: &'life1 str, keys: Vec<String>, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn compare_and_swap<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, expected_version: u64, new_value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn get_modified_since<'life0, 'life1, 'async_trait, T>( &'life0 self, table: &'life1 str, since: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static, 'life0: 'async_trait, 'life1: 'async_trait; fn get_expiring_before<'life0, 'life1, 'async_trait, T>( &'life0 self, table: &'life1 str, before: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>> where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static, 'life0: 'async_trait, 'life1: 'async_trait; fn cleanup_expired<'life0, 'life1, 'async_trait>( &'life0 self, table: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn compact<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn flush<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn shutdown<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Core storage trait defining unified interface for all backends

Required Methods§

Source

fn backend(&self) -> StorageBackend

Get backend type

Source

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

Get storage metadata

Source

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

Health check

Source

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

Get statistics

Source

fn insert<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + Serialize + DeserializeOwned + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Insert a new entry

Source

fn insert_with_ttl<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ttl_seconds: i64, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Insert entry with TTL (time-to-live in seconds)

Source

fn get<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Option<StorageEntry<T>>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get an entry by key

Source

fn update<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Update an existing entry

Source

fn update_versioned<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, expected_version: u64, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Update entry with optimistic locking (version check)

Source

fn delete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, table: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete an entry

Source

fn exists<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, table: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if entry exists

Source

fn execute_batch<'life0, 'async_trait>( &'life0 self, batch: Batch, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute batch operations

Source

fn query<'life0, 'async_trait, T>( &'life0 self, query: Query, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static, 'life0: 'async_trait,

Query entries matching criteria

Source

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

Count entries matching criteria

Source

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

Begin a transaction

Source

fn commit_transaction<'life0, 'async_trait>( &'life0 self, transaction: Transaction, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Commit a transaction

Source

fn rollback_transaction<'life0, 'async_trait>( &'life0 self, transaction: Transaction, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Rollback a transaction

Source

fn scan_prefix<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, table: &'life1 str, prefix: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Scan keys with prefix

Source

fn get_multi<'life0, 'life1, 'async_trait, T>( &'life0 self, table: &'life1 str, keys: Vec<String>, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Option<StorageEntry<T>>>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait,

Get multiple entries by keys

Source

fn delete_multi<'life0, 'life1, 'async_trait>( &'life0 self, table: &'life1 str, keys: Vec<String>, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete multiple entries

Source

fn compare_and_swap<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, expected_version: u64, new_value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + Serialize + Send + Sync, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Atomic compare-and-swap

Source

fn get_modified_since<'life0, 'life1, 'async_trait, T>( &'life0 self, table: &'life1 str, since: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static, 'life0: 'async_trait, 'life1: 'async_trait,

Get entries modified after timestamp

Source

fn get_expiring_before<'life0, 'life1, 'async_trait, T>( &'life0 self, table: &'life1 str, before: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static, 'life0: 'async_trait, 'life1: 'async_trait,

Get entries that expire before timestamp

Source

fn cleanup_expired<'life0, 'life1, 'async_trait>( &'life0 self, table: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Cleanup expired entries

Source

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

Compact storage (if supported)

Source

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

Flush pending writes

Source

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

Initialize storage

Source

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

Shutdown storage

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§