pub trait StorageEngine:
Send
+ Sync
+ 'static {
// Required methods
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 Key,
value: &'life2 CipherBlob,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Key,
) -> Pin<Box<dyn Future<Output = Result<Option<CipherBlob>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn atomic_update<'life0, 'life1, 'async_trait, F>(
&'life0 self,
key: &'life1 Key,
f: F,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where F: Fn(&CipherBlob) -> Result<CipherBlob> + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Key,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn range<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
start: &'life1 Key,
end: &'life2 Key,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Key, CipherBlob)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Key>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn contains<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Key,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Core storage engine trait
All storage implementations (in-memory, LSM-Tree, etc.) must implement this trait. Operations are async and guarantee durability (fsync) on success.
Required Methods§
Sourcefn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 Key,
value: &'life2 CipherBlob,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 Key,
value: &'life2 CipherBlob,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Write data with fsync guarantee
§Errors
Returns IoError if write fails or StorageIntegrity if corruption detected
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Key,
) -> Pin<Box<dyn Future<Output = Result<Option<CipherBlob>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Key,
) -> Pin<Box<dyn Future<Output = Result<Option<CipherBlob>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read data, returns None if key doesn’t exist
§Errors
Returns IoError if read fails or StorageIntegrity if data corrupted
Sourcefn atomic_update<'life0, 'life1, 'async_trait, F>(
&'life0 self,
key: &'life1 Key,
f: F,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
F: Fn(&CipherBlob) -> Result<CipherBlob> + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn atomic_update<'life0, 'life1, 'async_trait, F>(
&'life0 self,
key: &'life1 Key,
f: F,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
F: Fn(&CipherBlob) -> Result<CipherBlob> + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Atomic update operation (Read-Modify-Write)
Strictly eliminates race conditions by holding a lock during the operation.
§Errors
Returns error if read/write fails or if update function returns error
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Key,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 Key,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn range<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
start: &'life1 Key,
end: &'life2 Key,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Key, CipherBlob)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn range<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
start: &'life1 Key,
end: &'life2 Key,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Key, CipherBlob)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Key>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Key>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
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.