pub struct Tx { /* private fields */ }Expand description
Transaction handle that owns the SQLite connection until completion.
Implementations§
Source§impl Tx
impl Tx
Sourcepub fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
pub fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
Prepare a statement within this transaction.
§Errors
Returns SqlMiddlewareDbError if the transaction has already completed.
Sourcepub async fn execute_prepared(
&mut self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<usize, SqlMiddlewareDbError>
pub async fn execute_prepared( &mut self, prepared: &Prepared, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>
Execute a prepared statement as DML within this transaction.
§Errors
Returns SqlMiddlewareDbError if parameter conversion or execution fails.
Sourcepub async fn query_prepared(
&mut self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn query_prepared( &mut self, prepared: &Prepared, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute a prepared statement as a query within this transaction.
§Errors
Returns SqlMiddlewareDbError if parameter conversion or execution fails.
Sourcepub async fn execute_batch(
&mut self,
sql: &str,
) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch( &mut self, sql: &str, ) -> Result<(), SqlMiddlewareDbError>
Execute a batch inside the open transaction.
§Errors
Returns SqlMiddlewareDbError if executing the batch fails.
Sourcepub async fn commit(self) -> Result<TxOutcome, SqlMiddlewareDbError>
pub async fn commit(self) -> Result<TxOutcome, SqlMiddlewareDbError>
Commit the transaction and surface the restored connection.
§Errors
Returns SqlMiddlewareDbError if committing the transaction fails.
Use the returned connection (via TxOutcome::into_restored_connection)
for further work so the pool wrapper and placeholder-translation flag stay in sync.
Sourcepub async fn rollback(self) -> Result<TxOutcome, SqlMiddlewareDbError>
pub async fn rollback(self) -> Result<TxOutcome, SqlMiddlewareDbError>
Roll back the transaction and surface the restored connection.
§Errors
Returns SqlMiddlewareDbError if rolling back fails.
Use the returned connection (via TxOutcome::into_restored_connection)
for further work so the pool wrapper and placeholder-translation flag stay in sync.