pub struct Transaction { /* private fields */ }Expand description
A database transaction.
Created by Pool::begin(). Must be explicitly
committed via commit(). If dropped without
commit(), the connection is discarded from the pool (unless no queries
were executed, in which case BEGIN was never sent and the connection
is clean).
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub async fn commit(self) -> BsqlResult<()>
pub async fn commit(self) -> BsqlResult<()>
Commit the transaction and return the connection to the pool.
Consumes self — the transaction cannot be used after commit.
If no queries were executed (BEGIN was never sent), this is a
no-op: no COMMIT is sent and the connection returns cleanly.
Sourcepub async fn rollback(self) -> BsqlResult<()>
pub async fn rollback(self) -> BsqlResult<()>
Explicitly roll back the transaction and return the connection to the pool.
Consumes self — the transaction cannot be used after rollback.
If no queries were executed (BEGIN was never sent), this is a
no-op: no ROLLBACK is sent and the connection returns cleanly.