Tx

Struct Tx 

Source
pub struct Tx<E = Error> { /* private fields */ }

Methods from Deref<Target = Transaction<'static>>§

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 query_typed( &self, statement: &str, params: &[(&(dyn ToSql + Sync), Type)], ) -> Result<Vec<Row>, Error>

Like Client::query_typed.

Source

pub async fn query_typed_raw<P, I>( &self, query: &str, params: I, ) -> Result<RowStream, Error>
where P: BorrowToSql, I: IntoIterator<Item = (P, Type)>,

Like Client::query_typed_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 fn client(&self) -> &Client

Returns a reference to the underlying Client.

Trait Implementations§

Source§

impl<E> AsRef<Transaction<'static>> for Tx<E>

Source§

fn as_ref(&self) -> &Transaction<'static>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<E> Deref for Tx<E>

Source§

type Target = Transaction<'static>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<S, E> FromRequestParts<S> for Tx<E>
where S: Sync, E: From<Error> + IntoResponse,

Source§

type Rejection = E

If the extractor fails it’ll use this “rejection” type. A rejection is a kind of error that can be converted into a response.
Source§

async fn from_request_parts( parts: &mut Parts, _state: &S, ) -> Result<Self, Self::Rejection>

Perform the extraction.

Auto Trait Implementations§

§

impl<E> Freeze for Tx<E>

§

impl<E = Error> !RefUnwindSafe for Tx<E>

§

impl<E> Send for Tx<E>
where E: Send,

§

impl<E> Sync for Tx<E>
where E: Sync,

§

impl<E> Unpin for Tx<E>
where E: Unpin,

§

impl<E = Error> !UnwindSafe for Tx<E>

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<S, T> FromRequest<S, ViaParts> for T
where S: Send + Sync, T: FromRequestParts<S>,

Source§

type Rejection = <T as FromRequestParts<S>>::Rejection

If the extractor fails it’ll use this “rejection” type. A rejection is a kind of error that can be converted into a response.
Source§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>

Perform the extraction.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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