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§
Sourcefn query(
&self,
sql: &str,
params: &[QueryParam],
) -> Result<Vec<Row>, StorageError>
fn query( &self, sql: &str, params: &[QueryParam], ) -> Result<Vec<Row>, StorageError>
Execute a query that returns rows.
Sourcefn execute(&self, sql: &str, params: &[QueryParam]) -> Result<u64, StorageError>
fn execute(&self, sql: &str, params: &[QueryParam]) -> Result<u64, StorageError>
Execute a statement that modifies data (INSERT, UPDATE, DELETE).
Sourcefn begin_transaction(&self) -> Result<(), StorageError>
fn begin_transaction(&self) -> Result<(), StorageError>
Begin a transaction.
Sourcefn commit(&self) -> Result<(), StorageError>
fn commit(&self) -> Result<(), StorageError>
Commit the current transaction.
Sourcefn rollback(&self) -> Result<(), StorageError>
fn rollback(&self) -> Result<(), StorageError>
Rollback the current transaction.
Sourcefn backend_type(&self) -> &str
fn backend_type(&self) -> &str
Get the backend type name.
Sourcefn is_healthy(&self) -> bool
fn is_healthy(&self) -> bool
Check if the backend is healthy/connected.