StorageEngine

Trait StorageEngine 

Source
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§

Source

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

Source

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

Source

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

Source

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,

Delete a key

§Errors

Returns IoError if deletion fails

Source

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,

Range scan from start (inclusive) to end (exclusive)

§Errors

Returns IoError if scan fails

Source

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,

Get all keys in the storage (for debugging/admin)

§Errors

Returns IoError if scan fails

Source

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

Flush all pending writes to disk

§Errors

Returns IoError if flush fails

Source

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

Close the storage engine gracefully

§Errors

Returns IoError if close fails

Provided Methods§

Source

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,

Check if a key exists

§Errors

Returns IoError if check fails

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§