Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend:
    Send
    + Sync
    + Debug {
    // Required methods
    fn query(
        &self,
        sql: &str,
        params: &[QueryParam],
    ) -> Result<Vec<Row>, StorageError>;
    fn execute(
        &self,
        sql: &str,
        params: &[QueryParam],
    ) -> Result<u64, StorageError>;
    fn begin_transaction(&self) -> Result<(), StorageError>;
    fn commit(&self) -> Result<(), StorageError>;
    fn rollback(&self) -> Result<(), StorageError>;
    fn backend_type(&self) -> &str;
    fn is_healthy(&self) -> bool;
}
Expand description

Abstract storage backend trait. SQLite is the default; PostgreSQL is available as an opt-in alternative.

Required Methods§

Source

fn query( &self, sql: &str, params: &[QueryParam], ) -> Result<Vec<Row>, StorageError>

Execute a query that returns rows.

Source

fn execute(&self, sql: &str, params: &[QueryParam]) -> Result<u64, StorageError>

Execute a statement that modifies data (INSERT, UPDATE, DELETE).

Source

fn begin_transaction(&self) -> Result<(), StorageError>

Begin a transaction.

Source

fn commit(&self) -> Result<(), StorageError>

Commit the current transaction.

Source

fn rollback(&self) -> Result<(), StorageError>

Rollback the current transaction.

Source

fn backend_type(&self) -> &str

Get the backend type name.

Source

fn is_healthy(&self) -> bool

Check if the backend is healthy/connected.

Implementors§