pub struct Tx<'a> { /* private fields */ }Expand description
Lightweight transaction wrapper for Postgres.
Implementations§
Source§impl<'conn> Tx<'conn>
impl<'conn> Tx<'conn>
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 fn select<'tx, 'prepared>(
&'tx self,
prepared: &'prepared Prepared,
) -> PreparedSelect<'tx, 'prepared, 'static, 'conn>
pub fn select<'tx, 'prepared>( &'tx self, prepared: &'prepared Prepared, ) -> PreparedSelect<'tx, 'prepared, 'static, 'conn>
Start configuring a prepared SELECT execution.
Sourcepub fn execute<'tx, 'prepared>(
&'tx self,
prepared: &'prepared Prepared,
) -> PreparedExecute<'tx, 'prepared, 'static, 'conn>
pub fn execute<'tx, 'prepared>( &'tx self, prepared: &'prepared Prepared, ) -> PreparedExecute<'tx, 'prepared, 'static, 'conn>
Start configuring a prepared DML execution.
Sourcepub async fn execute_dml(
&self,
query: &str,
params: &[RowValues],
) -> Result<usize, SqlMiddlewareDbError>
pub async fn execute_dml( &self, query: &str, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>
Execute a parameterized DML statement without preparing and return affected rows.
§Errors
Returns an error if parameter conversion, execution, or row-count conversion fails.
Sourcepub async fn query(
&self,
query: &str,
params: &[RowValues],
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn query( &self, query: &str, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute a parameterized SELECT without preparing and return a ResultSet.
§Errors
Returns an error if parameter conversion or query execution 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> 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