Struct Transaction

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

Implementations§

Source§

impl<C> Transaction<'_, C>

Source

pub fn builder() -> TransactionBuilder

Source

pub async fn bind<'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 bind_raw<'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 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>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<C> Prepare for Transaction<'_, C>

Source§

fn _get_type( &self, oid: Oid, ) -> Pin<Box<dyn Future<Output = Result<Type, Error>> + Send + '_>>

Source§

fn _get_type_blocking(&self, oid: Oid) -> Result<Type, Error>

Source§

impl<C> Query for Transaction<'_, C>

Source§

fn _send_encode_query<S>(&self, stmt: S) -> Result<(S::Output, Response), Error>
where S: Encode,

encode statement and params and send it to client driver
Source§

fn _query<S>( &self, stmt: S, ) -> Result<<S::Output as IntoResponse>::Response, Error>
where S: Encode,

query with statement and dynamic typed params. Read more

Auto Trait Implementations§

§

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

§

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>

§

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

§

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<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