pub trait StorageBackend {
// Required methods
fn execute_sql(
&self,
sql: &str,
params: &[&dyn ToSql],
) -> Result<usize, AppError>;
fn query_one<T, F>(
&self,
sql: &str,
params: &[&dyn ToSql],
f: F,
) -> Result<Option<T>, AppError>
where F: FnOnce(&Row<'_>) -> Result<T, Error>;
fn as_connection(&self) -> &Connection;
}Expand description
Backend-agnostic storage abstraction.
Phase 1: wraps rusqlite::Connection without functional change.
Phase 2: will be implemented for libsql::Connection with embedded replicas.
Required Methods§
Sourcefn execute_sql(
&self,
sql: &str,
params: &[&dyn ToSql],
) -> Result<usize, AppError>
fn execute_sql( &self, sql: &str, params: &[&dyn ToSql], ) -> Result<usize, AppError>
Execute a SQL statement and return the number of affected rows.
Sourcefn query_one<T, F>(
&self,
sql: &str,
params: &[&dyn ToSql],
f: F,
) -> Result<Option<T>, AppError>
fn query_one<T, F>( &self, sql: &str, params: &[&dyn ToSql], f: F, ) -> Result<Option<T>, AppError>
Query a single row and map it with the provided closure.
Sourcefn as_connection(&self) -> &Connection
fn as_connection(&self) -> &Connection
Returns a reference to the underlying rusqlite Connection. Phase 1 escape hatch — will be removed when full migration is complete.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".