Struct deadpool_postgres::Transaction

source ·
pub struct Transaction<'a> {
    pub statement_cache: Arc<StatementCache>,
    /* private fields */
}
Expand description

Wrapper around tokio_postgres::Transaction with a StatementCache from the Client object it was created by.

Fields§

§statement_cache: Arc<StatementCache>

Implementations§

source§

impl<'a> Transaction<'a>

source

pub async fn prepare_cached(&self, query: &str) -> Result<Statement, Error>

Like tokio_postgres::Transaction::prepare(), but uses an existing Statement from the StatementCache if possible.

source

pub async fn prepare_typed_cached( &self, query: &str, types: &[Type] ) -> Result<Statement, Error>

Like tokio_postgres::Transaction::prepare_typed(), but uses an existing Statement from the StatementCache if possible.

source

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

source

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

source

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

source

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

Methods from Deref<Target = PgTransaction<'a>>§

source

pub async fn prepare(&self, query: &str) -> Result<Statement, Error>

Like Client::prepare.

source

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

Like Client::prepare_typed.

source

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

Like Client::query.

source

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

Like Client::query_one.

source

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

Like Client::query_opt.

source

pub async fn query_raw<T, P, I>( &self, statement: &T, params: I ) -> Result<RowStream, Error>

Like Client::query_raw.

source

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

Like Client::execute.

source

pub async fn execute_raw<P, I, T>( &self, statement: &T, params: I ) -> Result<u64, Error>

Like Client::execute_iter.

source

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

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.

source

pub async fn bind_raw<P, T, I>( &self, statement: &T, params: I ) -> Result<Portal, Error>

A maximally flexible version of bind.

source

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

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.

source

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

The maximally flexible version of query_portal.

source

pub async fn copy_in<T, U>(&self, statement: &T) -> Result<CopyInSink<U>, Error>
where T: ToStatement + ?Sized, U: Buf + 'static + Send,

Like Client::copy_in.

source

pub async fn copy_out<T>(&self, statement: &T) -> Result<CopyOutStream, Error>
where T: ToStatement + ?Sized,

Like Client::copy_out.

source

pub async fn simple_query( &self, query: &str ) -> Result<Vec<SimpleQueryMessage>, Error>

Like Client::simple_query.

source

pub async fn batch_execute(&self, query: &str) -> Result<(), Error>

Like Client::batch_execute.

source

pub fn cancel_token(&self) -> CancelToken

Like Client::cancel_token.

source

pub async fn cancel_query<T>(&self, tls: T) -> Result<(), Error>

👎Deprecated since 0.6.0: use Transaction::cancel_token() instead

Like Client::cancel_query.

source

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

👎Deprecated since 0.6.0: use Transaction::cancel_token() instead

Like Client::cancel_query_raw.

source

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

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

source

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

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

source

pub fn client(&self) -> &Client

Returns a reference to the underlying Client.

Trait Implementations§

source§

impl<'a> Debug for Transaction<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Deref for Transaction<'a>

§

type Target = Transaction<'a>

The resulting type after dereferencing.
source§

fn deref(&self) -> &PgTransaction<'a>

Dereferences the value.
source§

impl<'a> DerefMut for Transaction<'a>

source§

fn deref_mut(&mut self) -> &mut PgTransaction<'a>

Mutably dereferences the value.
source§

impl GenericClient for Transaction<'_>

source§

fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, query: &'life1 T, params: &'life2 [&'life3 (dyn ToSql + Sync)] ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where T: ?Sized + ToStatement + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Like Client::execute.
source§

fn execute_raw<'life0, 'life1, 'async_trait, P, I, T>( &'life0 self, statement: &'life1 T, params: I ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where T: ?Sized + ToStatement + Sync + Send + 'async_trait, P: BorrowToSql + 'async_trait, I: IntoIterator<Item = P> + Sync + Send + 'async_trait, I::IntoIter: ExactSizeIterator, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like Client::execute_raw.
source§

fn query<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, query: &'life1 T, params: &'life2 [&'life3 (dyn ToSql + Sync)] ) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, Error>> + Send + 'async_trait>>
where T: ?Sized + ToStatement + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Like Client::query.
source§

fn query_one<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, statement: &'life1 T, params: &'life2 [&'life3 (dyn ToSql + Sync)] ) -> Pin<Box<dyn Future<Output = Result<Row, Error>> + Send + 'async_trait>>
where T: ?Sized + ToStatement + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Like Client::query_one.
source§

fn query_opt<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, statement: &'life1 T, params: &'life2 [&'life3 (dyn ToSql + Sync)] ) -> Pin<Box<dyn Future<Output = Result<Option<Row>, Error>> + Send + 'async_trait>>
where T: ?Sized + ToStatement + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Like Client::query_opt.
source§

fn query_raw<'life0, 'life1, 'async_trait, T, P, I>( &'life0 self, statement: &'life1 T, params: I ) -> Pin<Box<dyn Future<Output = Result<RowStream, Error>> + Send + 'async_trait>>
where T: ?Sized + ToStatement + Sync + Send + 'async_trait, P: BorrowToSql + 'async_trait, I: IntoIterator<Item = P> + Sync + Send + 'async_trait, I::IntoIter: ExactSizeIterator, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like Client::query_raw.
source§

fn prepare<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like Client::prepare.
source§

fn prepare_typed<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, query: &'life1 str, parameter_types: &'life2 [Type] ) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Like Client::prepare_typed.
source§

fn prepare_cached<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn prepare_typed_cached<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, query: &'life1 str, types: &'life2 [Type] ) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

source§

fn transaction<'a, 'async_trait>( &'a mut self ) -> Pin<Box<dyn Future<Output = Result<Transaction<'a>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Like Client::transaction.
source§

fn batch_execute<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like Client::batch_execute.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

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

§

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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more