Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend:
    Debug
    + Send
    + Sync {
    // Required methods
    fn clear_table(&self, table: &'static str) -> Result<(), StoreError>;
    fn begin_read(&self) -> Result<Arc<dyn StorageReadView>, StoreError>;
    fn begin_write(
        &self,
    ) -> Result<Box<dyn StorageWriteBatch + 'static>, StoreError>;
    fn begin_locked(
        &self,
        table_name: &'static str,
    ) -> Result<Box<dyn StorageLockedView + 'static>, StoreError>;
    fn create_checkpoint(&self, path: &Path) -> Result<(), StoreError>;
}
Expand description

This trait provides a minimal set of operations required from a database backend. Implementations should focus on providing efficient access to the underlying storage without implementing business logic.

Required Methods§

Source

fn clear_table(&self, table: &'static str) -> Result<(), StoreError>

Removes all data from the specified table.

Source

fn begin_read(&self) -> Result<Arc<dyn StorageReadView>, StoreError>

Opens a new read view.

Source

fn begin_write( &self, ) -> Result<Box<dyn StorageWriteBatch + 'static>, StoreError>

Creates a new write batch.

Source

fn begin_locked( &self, table_name: &'static str, ) -> Result<Box<dyn StorageLockedView + 'static>, StoreError>

Creates a locked snapshot for a specific table.

This provides a persistent read-only view of a single table, optimized for batch read operations. The snapshot remains valid until dropped.

Source

fn create_checkpoint(&self, path: &Path) -> Result<(), StoreError>

Creates a checkpoint of the current database state at the specified path.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§