pub struct SqliteConnection { /* private fields */ }Expand description
Owned SQLite connection backed by a dedicated worker thread.
Implementations§
Source§impl SqliteConnection
impl SqliteConnection
Sourcepub fn new(object: Object) -> Result<Self, SqlMiddlewareDbError>
pub fn new(object: Object) -> Result<Self, SqlMiddlewareDbError>
Construct a worker-backed SQLite connection handle.
§Errors
Returns SqlMiddlewareDbError if the background worker thread cannot be spawned.
Sourcepub async fn execute_batch(
&self,
query: String,
) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch( &self, query: String, ) -> Result<(), SqlMiddlewareDbError>
Execute a batch of SQL statements on the worker-owned connection.
§Errors
Propagates any SqlMiddlewareDbError produced while dispatching the command or running
the query batch within the worker.
Sourcepub async fn execute_select(
&self,
query: String,
params: Vec<Value>,
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn execute_select( &self, query: String, params: Vec<Value>, ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute a SQL query and return a ResultSet produced by the worker thread.
§Errors
Returns any SqlMiddlewareDbError encountered while the worker prepares or evaluates the
statement, or if channel communication with the worker fails.
Sourcepub async fn execute_dml(
&self,
query: String,
params: Vec<Value>,
) -> Result<usize, SqlMiddlewareDbError>
pub async fn execute_dml( &self, query: String, params: Vec<Value>, ) -> Result<usize, SqlMiddlewareDbError>
Execute a DML statement (INSERT/UPDATE/DELETE) and return the affected row count.
§Errors
Returns any SqlMiddlewareDbError reported by the worker while executing the statement or
relaying the result back to the caller.
Sourcepub async fn with_connection<F, R>(
&self,
func: F,
) -> Result<R, SqlMiddlewareDbError>where
F: FnOnce(&mut Connection) -> Result<R, SqlMiddlewareDbError> + Send + 'static,
R: Send + 'static,
pub async fn with_connection<F, R>(
&self,
func: F,
) -> Result<R, SqlMiddlewareDbError>where
F: FnOnce(&mut Connection) -> Result<R, SqlMiddlewareDbError> + Send + 'static,
R: Send + 'static,
Run synchronous rusqlite logic against the underlying worker-owned connection.
§Errors
Propagates any SqlMiddlewareDbError raised while executing the callback or interacting
with the worker.
Sourcepub async fn prepare_statement(
&self,
query: &str,
) -> Result<SqlitePreparedStatement, SqlMiddlewareDbError>
pub async fn prepare_statement( &self, query: &str, ) -> Result<SqlitePreparedStatement, SqlMiddlewareDbError>
Prepare a cached statement on the worker and return a reusable handle.
§Errors
Returns SqlMiddlewareDbError if the worker fails to prepare the statement or if the
preparation channel is unexpectedly closed.
Trait Implementations§
Source§impl Clone for SqliteConnection
impl Clone for SqliteConnection
Source§fn clone(&self) -> SqliteConnection
fn clone(&self) -> SqliteConnection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more