[][src]Struct tokio_postgres::Transaction

pub struct Transaction<'a> { /* fields omitted */ }

A representation of a PostgreSQL database transaction.

Transactions will implicitly roll back when dropped. Use the commit method to commit the changes made in the transaction. Transactions can be nested, with inner transactions implemented via safepoints.

Methods

impl<'a> Transaction<'a>[src]

pub async fn commit(__arg0: Self) -> Result<(), Error>[src]

Consumes the transaction, committing all changes made within it.

pub async fn rollback(__arg0: Self) -> Result<(), Error>[src]

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.

pub async fn prepare<'_, '_>(
    &'_ self,
    query: &'_ str
) -> Result<Statement, Error>
[src]

Like Client::prepare.

pub async fn prepare_typed<'_, '_, '_>(
    &'_ self,
    query: &'_ str,
    parameter_types: &'_ [Type]
) -> Result<Statement, Error>
[src]

Like Client::prepare_typed.

pub async fn query<'_, '_, '_, '_, T: ?Sized>(
    &'_ self,
    statement: &'_ T,
    params: &'_ [&'_ (dyn ToSql + Sync)]
) -> Result<Vec<Row>, Error> where
    T: ToStatement
[src]

Like Client::query.

pub async fn query_one<'_, '_, '_, '_, T: ?Sized>(
    &'_ self,
    statement: &'_ T,
    params: &'_ [&'_ (dyn ToSql + Sync)]
) -> Result<Row, Error> where
    T: ToStatement
[src]

Like Client::query_one.

pub async fn query_raw<'b, '_, '_, T: ?Sized, I>(
    &'_ self,
    statement: &'_ T,
    params: I
) -> Result<RowStream, Error> where
    T: ToStatement,
    I: IntoIterator<Item = &'b dyn ToSql>,
    I::IntoIter: ExactSizeIterator
[src]

Like Client::query_raw.

pub async fn execute<'_, '_, '_, '_, T: ?Sized>(
    &'_ self,
    statement: &'_ T,
    params: &'_ [&'_ (dyn ToSql + Sync)]
) -> Result<u64, Error> where
    T: ToStatement
[src]

Like Client::execute.

pub async fn execute_raw<'b, '_, '_, I, T: ?Sized>(
    &'_ self,
    statement: &'_ Statement,
    params: I
) -> Result<u64, Error> where
    T: ToStatement,
    I: IntoIterator<Item = &'b dyn ToSql>,
    I::IntoIter: ExactSizeIterator
[src]

Like Client::execute_iter.

pub async fn bind<'_, '_, '_, '_, T: ?Sized>(
    &'_ self,
    statement: &'_ T,
    params: &'_ [&'_ (dyn ToSql + Sync)]
) -> Result<Portal, Error> where
    T: ToStatement
[src]

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.

Panics

Panics if the number of parameters provided does not match the number expected.

pub async fn bind_iter<'b, '_, '_, T: ?Sized, I>(
    &'_ self,
    statement: &'_ T,
    params: I
) -> Result<Portal, Error> where
    T: ToStatement,
    I: IntoIterator<Item = &'b dyn ToSql>,
    I::IntoIter: ExactSizeIterator
[src]

Like bind, but takes an iterator of parameters rather than a slice.

pub async fn query_portal<'_, '_>(
    &'_ self,
    portal: &'_ Portal,
    max_rows: i32
) -> Result<Vec<Row>, Error>
[src]

Continues execution of a portal, returning a stream of the resulting rows.

Unlike query, portals can be incrementally evaluated by limiting the number of rows returned in each call to query_portal. If the requested number is negative or 0, all rows will be returned.

pub async fn query_portal_raw<'_, '_>(
    &'_ self,
    portal: &'_ Portal,
    max_rows: i32
) -> Result<RowStream, Error>
[src]

The maximally flexible version of query_portal.

pub async fn copy_in<'_, '_, '_, '_, T: ?Sized, S>(
    &'_ self,
    statement: &'_ T,
    params: &'_ [&'_ (dyn ToSql + Sync)],
    stream: S
) -> Result<u64, Error> where
    T: ToStatement,
    S: TryStream,
    S::Ok: IntoBuf,
    <S::Ok as IntoBuf>::Buf: 'static + Send,
    S::Error: Into<Box<dyn Error + Sync + Send>>, 
[src]

Like Client::copy_in.

pub async fn copy_out<'_, '_, '_, '_, T: ?Sized>(
    &'_ self,
    statement: &'_ T,
    params: &'_ [&'_ (dyn ToSql + Sync)]
) -> Result<CopyStream, Error> where
    T: ToStatement
[src]

Like Client::copy_out.

pub async fn simple_query<'_, '_>(
    &'_ self,
    query: &'_ str
) -> Result<Vec<SimpleQueryMessage>, Error>
[src]

Like Client::simple_query.

pub async fn batch_execute<'_, '_>(
    &'_ self,
    query: &'_ str
) -> Result<(), Error>
[src]

Like Client::batch_execute.

pub async fn cancel_query<'_, T>(&'_ self, tls: T) -> Result<(), Error> where
    T: MakeTlsConnect<Socket>, 
[src]

Like Client::cancel_query.

pub async fn cancel_query_raw<'_, S, T>(
    &'_ self,
    stream: S,
    tls: T
) -> Result<(), Error> where
    S: AsyncRead + AsyncWrite + Unpin,
    T: TlsConnect<S>, 
[src]

Like Client::cancel_query_raw.

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

Like Client::transaction.

Trait Implementations

impl<'a> Drop for Transaction<'a>[src]

Auto Trait Implementations

impl<'a> Send for Transaction<'a>

impl<'a> Sync for Transaction<'a>

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

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

impl<'a> !RefUnwindSafe for Transaction<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self