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>;
// Provided methods
fn flush(&self) -> Result<(), StoreError> { ... }
fn db_stats(&self) -> Option<RocksDbStats> { ... }
}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§
Sourcefn clear_table(&self, table: &'static str) -> Result<(), StoreError>
fn clear_table(&self, table: &'static str) -> Result<(), StoreError>
Removes all data from the specified table.
Sourcefn begin_read(&self) -> Result<Arc<dyn StorageReadView>, StoreError>
fn begin_read(&self) -> Result<Arc<dyn StorageReadView>, StoreError>
Opens a new read view.
Sourcefn begin_write(
&self,
) -> Result<Box<dyn StorageWriteBatch + 'static>, StoreError>
fn begin_write( &self, ) -> Result<Box<dyn StorageWriteBatch + 'static>, StoreError>
Creates a new write batch.
Sourcefn begin_locked(
&self,
table_name: &'static str,
) -> Result<Box<dyn StorageLockedView + 'static>, StoreError>
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.
Sourcefn create_checkpoint(&self, path: &Path) -> Result<(), StoreError>
fn create_checkpoint(&self, path: &Path) -> Result<(), StoreError>
Creates a checkpoint of the current database state at the specified path.
Provided Methods§
Sourcefn flush(&self) -> Result<(), StoreError>
fn flush(&self) -> Result<(), StoreError>
Durably persists all buffered writes to disk, so a subsequent process start needs no crash recovery. Called on graceful shutdown. Defaults to a no-op for backends that are already durable or purely in-memory.
Sourcefn db_stats(&self) -> Option<RocksDbStats>
fn db_stats(&self) -> Option<RocksDbStats>
Returns per-column-family and DB-wide RocksDB observability stats, or
None for backends that don’t expose them (e.g. in-memory).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".