pub struct Transaction<'a> { /* private fields */ }Expand description
An instrumented transaction, from Client::transaction. Like
tokio-postgres’s, dropping it without committing rolls it back, but that
rollback isn’t recorded. It dereferences to tokio-postgres’s
Transaction.
Implementations§
Source§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
Sourcepub async fn prepare(&self, query: &str) -> Result<Statement, Error>
pub async fn prepare(&self, query: &str) -> Result<Statement, Error>
Prepare a statement, keeping its text so that calls running it are named. Preparing isn’t recorded as a call.
Sourcepub async fn query<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Vec<Row>, Error>
pub async fn query<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Vec<Row>, Error>
Run a statement and return the rows it produced.
Sourcepub async fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Row, Error>
pub async fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Row, Error>
Run a statement that returns exactly one row.
Sourcepub async fn query_opt<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Option<Row>, Error>
pub async fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Option<Row>, Error>
Run a statement that returns at most one row.
Sourcepub async fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<u64, Error>
pub async fn execute<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<u64, Error>
Run a statement and return how many rows it changed.
Sourcepub async fn batch_execute(&self, query: &str) -> Result<(), Error>
pub async fn batch_execute(&self, query: &str) -> Result<(), Error>
Run statements separated by semicolons, without parameters, as one call.
Sourcepub async fn simple_query(
&self,
query: &str,
) -> Result<Vec<SimpleQueryMessage>, Error>
pub async fn simple_query( &self, query: &str, ) -> Result<Vec<SimpleQueryMessage>, Error>
Run statements through the simple query protocol, as one call.
Sourcepub async fn transaction(&mut self) -> Result<Transaction<'_>, Error>
pub async fn transaction(&mut self) -> Result<Transaction<'_>, Error>
Start a nested transaction, which is a savepoint, recorded as a call.
Methods from Deref<Target = Transaction<'a>>§
Sourcepub async fn prepare_typed(
&self,
query: &str,
parameter_types: &[Type],
) -> Result<Statement, Error>
pub async fn prepare_typed( &self, query: &str, parameter_types: &[Type], ) -> Result<Statement, Error>
Like Client::prepare_typed.
Sourcepub async fn query<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Vec<Row>, Error>where
T: ToStatement + ?Sized,
pub async fn query<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Vec<Row>, Error>where
T: ToStatement + ?Sized,
Like Client::query.
Sourcepub async fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Row, Error>where
T: ToStatement + ?Sized,
pub async fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Row, Error>where
T: ToStatement + ?Sized,
Like Client::query_one.
Sourcepub async fn query_opt<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Option<Row>, Error>where
T: ToStatement + ?Sized,
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.
Sourcepub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<RowStream, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
pub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<RowStream, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Like Client::query_raw.
Sourcepub async fn query_typed(
&self,
statement: &str,
params: &[(&(dyn ToSql + Sync), Type)],
) -> Result<Vec<Row>, Error>
pub async fn query_typed( &self, statement: &str, params: &[(&(dyn ToSql + Sync), Type)], ) -> Result<Vec<Row>, Error>
Like Client::query_typed.
Sourcepub async fn query_typed_one(
&self,
statement: &str,
params: &[(&(dyn ToSql + Sync), Type)],
) -> Result<Row, Error>
pub async fn query_typed_one( &self, statement: &str, params: &[(&(dyn ToSql + Sync), Type)], ) -> Result<Row, Error>
Like Client::query_typed_one.
Sourcepub async fn query_typed_opt(
&self,
statement: &str,
params: &[(&(dyn ToSql + Sync), Type)],
) -> Result<Option<Row>, Error>
pub async fn query_typed_opt( &self, statement: &str, params: &[(&(dyn ToSql + Sync), Type)], ) -> Result<Option<Row>, Error>
Like Client::query_typed_opt.
Sourcepub async fn query_typed_raw<P, I>(
&self,
query: &str,
params: I,
) -> Result<RowStream, Error>
pub async fn query_typed_raw<P, I>( &self, query: &str, params: I, ) -> Result<RowStream, Error>
Like Client::query_typed_raw.
Sourcepub async fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
pub async fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
Like Client::execute.
Sourcepub async fn execute_typed(
&self,
statement: &str,
params: &[(&(dyn ToSql + Sync), Type)],
) -> Result<u64, Error>
pub async fn execute_typed( &self, statement: &str, params: &[(&(dyn ToSql + Sync), Type)], ) -> Result<u64, Error>
Like Client::execute_typed.
Sourcepub async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I,
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
pub async fn execute_raw<P, I, T>(
&self,
statement: &T,
params: I,
) -> Result<u64, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Like Client::execute_iter.
Sourcepub async fn bind<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Portal, Error>where
T: ToStatement + ?Sized,
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.
Sourcepub async fn bind_raw<P, T, I>(
&self,
statement: &T,
params: I,
) -> Result<Portal, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
pub async fn bind_raw<P, T, I>(
&self,
statement: &T,
params: I,
) -> Result<Portal, Error>where
T: ToStatement + ?Sized,
P: BorrowToSql,
I: IntoIterator<Item = P>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
A maximally flexible version of bind.
Sourcepub async fn query_portal(
&self,
portal: &Portal,
max_rows: i32,
) -> Result<Vec<Row>, Error>
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.
Sourcepub async fn query_portal_raw(
&self,
portal: &Portal,
max_rows: i32,
) -> Result<RowStream, Error>
pub async fn query_portal_raw( &self, portal: &Portal, max_rows: i32, ) -> Result<RowStream, Error>
The maximally flexible version of query_portal.
Sourcepub async fn copy_in<T, U>(&self, statement: &T) -> Result<CopyInSink<U>, Error>
pub async fn copy_in<T, U>(&self, statement: &T) -> Result<CopyInSink<U>, Error>
Like Client::copy_in.
Sourcepub async fn copy_out<T>(&self, statement: &T) -> Result<CopyOutStream, Error>where
T: ToStatement + ?Sized,
pub async fn copy_out<T>(&self, statement: &T) -> Result<CopyOutStream, Error>where
T: ToStatement + ?Sized,
Like Client::copy_out.
Sourcepub async fn simple_query(
&self,
query: &str,
) -> Result<Vec<SimpleQueryMessage>, Error>
pub async fn simple_query( &self, query: &str, ) -> Result<Vec<SimpleQueryMessage>, Error>
Like Client::simple_query.
Sourcepub async fn batch_execute(&self, query: &str) -> Result<(), Error>
pub async fn batch_execute(&self, query: &str) -> Result<(), Error>
Like Client::batch_execute.
Sourcepub fn cancel_token(&self) -> CancelToken
pub fn cancel_token(&self) -> CancelToken
Like Client::cancel_token.
Sourcepub async fn cancel_query<T>(&self, tls: T) -> Result<(), Error>where
T: MakeTlsConnect<Socket>,
👎Deprecated since 0.6.0: use Transaction::cancel_token() instead
pub async fn cancel_query<T>(&self, tls: T) -> Result<(), Error>where
T: MakeTlsConnect<Socket>,
use Transaction::cancel_token() instead
Like Client::cancel_query.
Sourcepub async fn cancel_query_raw<S, T>(
&self,
stream: S,
tls: T,
) -> Result<(), Error>
👎Deprecated since 0.6.0: use Transaction::cancel_token() instead
pub async fn cancel_query_raw<S, T>( &self, stream: S, tls: T, ) -> Result<(), Error>
use Transaction::cancel_token() instead
Like Client::cancel_query_raw.
Trait Implementations§
Source§impl Debug for Transaction<'_>
impl Debug for Transaction<'_>
Source§impl<'a> Deref for Transaction<'a>
impl<'a> Deref for Transaction<'a>
Source§type Target = Transaction<'a>
type Target = Transaction<'a>
Source§fn deref(&self) -> &Transaction<'a>
fn deref(&self) -> &Transaction<'a>
Source§impl GenericClient for Transaction<'_>
impl GenericClient for Transaction<'_>
Source§fn prepare(
&self,
query: &str,
) -> impl Future<Output = Result<Statement, Error>> + Send
fn prepare( &self, query: &str, ) -> impl Future<Output = Result<Statement, Error>> + Send
Client::prepare.Source§fn query<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<Vec<Row>, Error>> + Send
fn query<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Vec<Row>, Error>> + Send
Client::query.Source§fn query_one<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<Row, Error>> + Send
fn query_one<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Row, Error>> + Send
Client::query_one.Source§fn query_opt<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<Option<Row>, Error>> + Send
fn query_opt<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<Option<Row>, Error>> + Send
Client::query_opt.Source§fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> impl Future<Output = Result<u64, Error>> + Send
fn execute<T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> impl Future<Output = Result<u64, Error>> + Send
Client::execute.Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Transaction<'a>
impl<'a> !UnwindSafe for Transaction<'a>
impl<'a> Freeze for Transaction<'a>
impl<'a> Send for Transaction<'a>
impl<'a> Sync for Transaction<'a>
impl<'a> Unpin for Transaction<'a>
impl<'a> UnsafeUnpin for Transaction<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more