pub struct Tx<'a> { /* private fields */ }Expand description
Lightweight transaction wrapper for Postgres.
Implementations§
Source§impl Tx<'_>
impl Tx<'_>
Sourcepub async fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
pub async fn prepare(&self, sql: &str) -> Result<Prepared, SqlMiddlewareDbError>
Prepare a SQL statement tied to this transaction.
§Errors
Returns an error if the prepare call fails.
Sourcepub async fn execute_prepared(
&self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<usize, SqlMiddlewareDbError>
pub async fn execute_prepared( &self, prepared: &Prepared, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>
Execute a parameterized DML statement and return the affected row count.
§Errors
Returns an error if parameter conversion, execution, or row-count conversion fails.
Sourcepub async fn query_prepared(
&self,
prepared: &Prepared,
params: &[RowValues],
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn query_prepared( &self, prepared: &Prepared, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute a parameterized SELECT and return a ResultSet.
§Errors
Returns an error if parameter conversion, execution, or result building fails.
Sourcepub async fn execute_batch(&self, sql: &str) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch(&self, sql: &str) -> Result<(), SqlMiddlewareDbError>
Execute a batch of SQL statements inside the transaction.
§Errors
Returns an error if execution fails.
Sourcepub async fn commit(self) -> Result<TxOutcome, SqlMiddlewareDbError>
pub async fn commit(self) -> Result<TxOutcome, SqlMiddlewareDbError>
Trait Implementations§
Source§impl<'a> From<&'a Tx<'a>> for BatchTarget<'a>
Available on crate feature postgres only.
impl<'a> From<&'a Tx<'a>> for BatchTarget<'a>
Available on crate feature
postgres only.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> !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