[−][src]Struct roa_pg::Transaction
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]
&'_ self,
query: &'_ str,
parameter_types: &'_ [Type]
) -> Result<Statement, Error>
Like Client::prepare_typed
.
pub async fn query<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement + ?Sized,
Like Client::query
.
pub async fn query_one<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Row, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Row, Error> where
T: ToStatement + ?Sized,
Like Client::query_one
.
pub async fn query_opt<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Option<Row>, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Option<Row>, Error> where
T: ToStatement + ?Sized,
Like Client::query_opt
.
pub async fn query_raw<'b, T, I>(
&'_ self,
statement: &'_ T,
params: I
) -> Result<RowStream, Error> where
I: IntoIterator<Item = &'b (dyn ToSql + 'b)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
[src]
&'_ self,
statement: &'_ T,
params: I
) -> Result<RowStream, Error> where
I: IntoIterator<Item = &'b (dyn ToSql + 'b)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Like Client::query_raw
.
pub async fn execute<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<u64, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<u64, Error> where
T: ToStatement + ?Sized,
Like Client::execute
.
pub async fn execute_raw<'b, I, T>(
&'_ self,
statement: &'_ T,
params: I
) -> Result<u64, Error> where
I: IntoIterator<Item = &'b (dyn ToSql + 'b)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
[src]
&'_ self,
statement: &'_ T,
params: I
) -> Result<u64, Error> where
I: IntoIterator<Item = &'b (dyn ToSql + 'b)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Like Client::execute_iter
.
pub async fn bind<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Portal, Error> where
T: ToStatement + ?Sized,
[src]
&'_ 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.
pub async fn bind_raw<'b, T, I>(
&'_ self,
statement: &'_ T,
params: I
) -> Result<Portal, Error> where
I: IntoIterator<Item = &'b (dyn ToSql + 'b)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
[src]
&'_ self,
statement: &'_ T,
params: I
) -> Result<Portal, Error> where
I: IntoIterator<Item = &'b (dyn ToSql + 'b)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
A maximally flexible version of bind
.
pub async fn query_portal(
&'_ self,
portal: &'_ Portal,
max_rows: i32
) -> Result<Vec<Row>, Error>
[src]
&'_ 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.
pub async fn query_portal_raw(
&'_ self,
portal: &'_ Portal,
max_rows: i32
) -> Result<RowStream, Error>
[src]
&'_ self,
portal: &'_ Portal,
max_rows: i32
) -> Result<RowStream, Error>
The maximally flexible version of query_portal
.
pub async fn copy_in<T, U>(
&'_ self,
statement: &'_ T
) -> Result<CopyInSink<U>, Error> where
T: ToStatement + ?Sized,
U: Buf + 'static + Send,
[src]
&'_ self,
statement: &'_ T
) -> Result<CopyInSink<U>, Error> where
T: ToStatement + ?Sized,
U: Buf + 'static + Send,
Like Client::copy_in
.
pub async fn copy_out<T>(
&'_ self,
statement: &'_ T
) -> Result<CopyOutStream, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T
) -> Result<CopyOutStream, Error> where
T: ToStatement + ?Sized,
Like Client::copy_out
.
pub async fn simple_query(
&'_ self,
query: &'_ str
) -> Result<Vec<SimpleQueryMessage>, Error>
[src]
&'_ self,
query: &'_ str
) -> Result<Vec<SimpleQueryMessage>, Error>
Like Client::simple_query
.
pub async fn batch_execute(&'_ self, query: &'_ str) -> Result<(), Error>
[src]
Like Client::batch_execute
.
pub fn cancel_token(&self) -> CancelToken
[src]
Like Client::cancel_token
.
pub async fn cancel_query_raw<S, T>(
&'_ self,
stream: S,
tls: T
) -> Result<(), Error> where
S: AsyncRead + AsyncWrite + Unpin,
T: TlsConnect<S>,
[src]
&'_ self,
stream: S,
tls: T
) -> Result<(), Error> where
S: AsyncRead + AsyncWrite + Unpin,
T: TlsConnect<S>,
use Transaction::cancel_token() instead
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]
impl<'_> GenericClient for Transaction<'_>
[src]
fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
fn execute_raw<'b, 'life0, 'life1, 'async_trait, I, T>(
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'async_trait + Send>> where
'b: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
I: IntoIterator<Item = &'b (dyn ToSql + 'b)> + Sync + Send + 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'async_trait + Send>> where
'b: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
I: IntoIterator<Item = &'b (dyn ToSql + 'b)> + Sync + Send + 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Transaction<'_>: 'async_trait,
fn query<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
query: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
fn query_one<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Row, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Row, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
fn query_opt<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Option<Row>, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
statement: &'life1 T,
params: &'life2 [&'life3 (dyn ToSql + 'life3 + Sync)]
) -> Pin<Box<dyn Future<Output = Result<Option<Row>, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
Transaction<'_>: 'async_trait,
fn query_raw<'b, 'life0, 'life1, 'async_trait, T, I>(
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<RowStream, Error>> + 'async_trait + Send>> where
'b: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
I: IntoIterator<Item = &'b (dyn ToSql + 'b)> + Sync + Send + 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
statement: &'life1 T,
params: I
) -> Pin<Box<dyn Future<Output = Result<RowStream, Error>> + 'async_trait + Send>> where
'b: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
I: IntoIterator<Item = &'b (dyn ToSql + 'b)> + Sync + Send + 'async_trait,
T: ToStatement + Sync + Send + 'async_trait + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
Transaction<'_>: 'async_trait,
fn prepare<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
query: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
Transaction<'_>: 'async_trait,
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>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Transaction<'_>: 'async_trait,
[src]
&'life0 self,
query: &'life1 str,
parameter_types: &'life2 [Type]
) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + 'async_trait + Send>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Transaction<'_>: 'async_trait,
fn transaction<'a, 'async_trait>(
&'a mut self
) -> Pin<Box<dyn Future<Output = Result<Transaction<'a>, Error>> + 'async_trait + Send>> where
'a: 'async_trait,
Transaction<'_>: 'async_trait,
[src]
&'a mut self
) -> Pin<Box<dyn Future<Output = Result<Transaction<'a>, Error>> + 'async_trait + Send>> where
'a: 'async_trait,
Transaction<'_>: 'async_trait,
Auto Trait Implementations
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,