Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction<'a, C>
where C: ClientBorrowMut,
{ /* private fields */ }

Implementations§

Source§

impl<C> Transaction<'_, C>
where C: ClientBorrowMut,

Source

pub async fn bind<'p, I>( &'p self, statement: &'p Statement, params: I, ) -> Result<Portal<'p, C>, Error>
where I: AsParams,

A maximally flexible version of Transaction::bind.

Source

pub async fn bind_dyn<'p>( &'p self, statement: &'p Statement, params: &[&(dyn ToSql + Sync)], ) -> Result<Portal<'p, C>, Error>

Binds a statement to a set of parameters, creating a Portal which can be incrementally queried.

Portals only last for the duration of the transaction in which they are created, and can only be used on the connection that created them.

Source

pub async fn transaction(&mut self) -> Result<Transaction<'_, C>, Error>

Like Client::transaction, but creates a nested transaction via a savepoint.

Source

pub async fn save_point<I>( &mut self, name: I, ) -> Result<Transaction<'_, C>, Error>
where I: Into<String>,

Like Client::transaction, but creates a nested transaction via a savepoint with the specified name.

Source

pub async fn commit(self) -> Result<(), Error>

Consumes the transaction, committing all changes made within it.

Source

pub async fn rollback(self) -> Result<(), Error>

Rolls the transaction back, discarding all changes made within it.

This is equivalent to Transaction’s Drop implementation, but provides any error encountered to the caller.

Trait Implementations§

Source§

impl<C> Drop for Transaction<'_, C>
where C: ClientBorrowMut,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, C> Freeze for Transaction<'a, C>
where C: Freeze,

§

impl<'a, C> RefUnwindSafe for Transaction<'a, C>
where C: RefUnwindSafe,

§

impl<'a, C> Send for Transaction<'a, C>
where C: Send,

§

impl<'a, C> Sync for Transaction<'a, C>
where C: Sync,

§

impl<'a, C> Unpin for Transaction<'a, C>
where C: Unpin,

§

impl<'a, C> UnsafeUnpin for Transaction<'a, C>
where C: UnsafeUnpin,

§

impl<'a, C> !UnwindSafe for Transaction<'a, C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<'c, C, Q, EO, QO> Execute<&'c Transaction<'_, C>> for Q
where C: ClientBorrowMut, Q: Execute<&'c Client, ExecuteOutput = EO, QueryOutput = QO>,

Source§

type ExecuteOutput = EO

outcome of execute. used for single time database response: number of rows affected by execution for example.
Source§

type QueryOutput = QO

outcome of query. used for repeated database response: database rows for example Read more
Source§

fn execute( self, cli: &'c Transaction<'_, C>, ) -> <Q as Execute<&'c Transaction<'_, C>>>::ExecuteOutput

define how a statement is executed with single time response
Source§

fn query( self, cli: &'c Transaction<'_, C>, ) -> <Q as Execute<&'c Transaction<'_, C>>>::QueryOutput

define how a statement is queried with repeated response
Source§

impl<'c, 'p, Q, EO, QO> Execute<&'c mut Transaction<'_, PoolConnection<'p>>> for Q
where Q: Execute<&'c mut PoolConnection<'p>, ExecuteOutput = EO, QueryOutput = QO>,

Source§

type ExecuteOutput = EO

outcome of execute. used for single time database response: number of rows affected by execution for example.
Source§

type QueryOutput = QO

outcome of query. used for repeated database response: database rows for example Read more
Source§

fn execute( self, cli: &'c mut Transaction<'_, PoolConnection<'p>>, ) -> <Q as Execute<&'c mut Transaction<'_, PoolConnection<'p>>>>::ExecuteOutput

define how a statement is executed with single time response
Source§

fn query( self, cli: &'c mut Transaction<'_, PoolConnection<'p>>, ) -> <Q as Execute<&'c mut Transaction<'_, PoolConnection<'p>>>>::QueryOutput

define how a statement is queried with repeated response
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V