actix_storage/provider/store.rs
1use std::sync::Arc;
2
3use crate::error::Result;
4
5/// Set of method for basic storage providers to implement.
6#[async_trait::async_trait]
7pub trait Store: Send + Sync {
8 /// Set a key-value pair, if the key already exist, value should be overwritten
9 async fn set(&self, scope: Arc<[u8]>, key: Arc<[u8]>, value: Arc<[u8]>) -> Result<()>;
10
11 /// Get a value for specified key, it should result in None if the value does not exist
12 async fn get(&self, scope: Arc<[u8]>, key: Arc<[u8]>) -> Result<Option<Arc<[u8]>>>;
13
14 /// Delete the key from storage, if the key doesn't exist, it shouldn't return an error
15 async fn delete(&self, scope: Arc<[u8]>, key: Arc<[u8]>) -> Result<()>;
16
17 /// Check if key exist in storage
18 async fn contains_key(&self, scope: Arc<[u8]>, key: Arc<[u8]>) -> Result<bool>;
19}