pub struct Tx<'a> { /* private fields */ }Expand description
Transaction handle that owns the SQLite connection until completion.
Implementations§
Source§impl<'conn> Tx<'conn>
impl<'conn> Tx<'conn>
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 fn select<'tx, 'prepared>(
&'tx mut self,
prepared: &'prepared Prepared,
) -> PreparedSelect<'tx, 'prepared, 'static, 'conn>
pub fn select<'tx, 'prepared>( &'tx mut self, prepared: &'prepared Prepared, ) -> PreparedSelect<'tx, 'prepared, 'static, 'conn>
Start configuring a prepared SELECT execution.
Sourcepub fn execute<'tx, 'prepared>(
&'tx mut self,
prepared: &'prepared Prepared,
) -> PreparedExecute<'tx, 'prepared, 'static, 'conn>
pub fn execute<'tx, 'prepared>( &'tx mut self, prepared: &'prepared Prepared, ) -> PreparedExecute<'tx, 'prepared, 'static, 'conn>
Start configuring a prepared DML execution.
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.
Trait Implementations§
Source§impl Drop for Tx<'_>
impl Drop for Tx<'_>
Source§fn drop(&mut self)
fn drop(&mut self)
Rolls back on drop to avoid leaking open transactions; the rollback is best-effort and
SQLite may report “no transaction is active” if the transaction was already completed
by user code (e.g., via execute_batch_in_tx). Such errors are ignored because the goal
is simply to leave the connection in a clean state before returning it to the pool.
Auto Trait Implementations§
impl<'a> Freeze for Tx<'a>
impl<'a> !RefUnwindSafe for Tx<'a>
impl<'a> Send for Tx<'a>
impl<'a> Sync for Tx<'a>
impl<'a> Unpin for Tx<'a>
impl<'a> UnsafeUnpin for Tx<'a>
impl<'a> !UnwindSafe for Tx<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more