pub struct Transaction<'a> { /* private fields */ }Expand description
A handle to one open transaction, passed to Database::transaction’s
closure.
Borrows the parent Database’s already-locked connection for the
transaction’s lifetime — execute/query take &self (via an
internal RefCell) so the closure can call either any number of times
without needing &mut.
This is the only way to run a statement inside the transaction: the
parent handle’s own execute/query/transaction report
DatabaseError::Reentrant for the whole span (see
Database::transaction).
Implementations§
Source§impl Transaction<'_>
impl Transaction<'_>
Sourcepub fn execute(
&self,
sql: &str,
params: impl IntoParams,
) -> Result<u64, DatabaseError>
pub fn execute( &self, sql: &str, params: impl IntoParams, ) -> Result<u64, DatabaseError>
Run a non-row-returning statement inside this transaction. See
Database::execute.
§Errors
DatabaseError::Sql if the engine rejects the statement.
Sourcepub fn query(
&self,
sql: &str,
params: impl IntoParams,
) -> Result<Vec<Row>, DatabaseError>
pub fn query( &self, sql: &str, params: impl IntoParams, ) -> Result<Vec<Row>, DatabaseError>
Run a row-returning statement inside this transaction. See
Database::query.
§Errors
DatabaseError::Sql if the engine rejects the statement.
Auto Trait Implementations§
impl<'a> !Freeze for Transaction<'a>
impl<'a> !RefUnwindSafe for Transaction<'a>
impl<'a> !Sync for Transaction<'a>
impl<'a> !UnwindSafe for Transaction<'a>
impl<'a> Send for Transaction<'a>
impl<'a> Unpin for Transaction<'a>
impl<'a> UnsafeUnpin for Transaction<'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