pub struct Transaction<'c, DB>where
DB: Database,{ /* private fields */ }Expand description
An in-progress database transaction or savepoint.
A transaction starts with a call to Pool::begin or Connection::begin.
A transaction should end with a call to commit or rollback. If neither are called
before the transaction goes out-of-scope, rollback is called. In other
words, rollback is called on drop if the transaction is still in-progress.
A savepoint is a special mark inside a transaction that allows all commands that are executed after it was established to be rolled back, restoring the transaction state to what it was at the time of the savepoint.
Implementations§
Trait Implementations§
Source§impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Any>
Available on (crate features postgres or mysql or mssql or sqlite or odbc) and crate feature any only.
impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Any>
Available on (crate features
postgres or mysql or mssql or sqlite or odbc) and crate feature any only.Source§impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Mssql>
Available on crate feature mssql only.
impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Mssql>
Available on crate feature
mssql only.Source§impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, MySql>
Available on crate feature mysql only.
impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, MySql>
Available on crate feature
mysql only.Source§impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Odbc>
Available on crate feature odbc only.
impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Odbc>
Available on crate feature
odbc only.Source§impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Postgres>
Available on crate feature postgres only.
impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Postgres>
Available on crate feature
postgres only.Source§impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Sqlite>
Available on crate feature sqlite only.
impl<'c, 't> Acquire<'t> for &'t mut Transaction<'c, Sqlite>
Available on crate feature
sqlite only.Source§impl<'c, DB> Debug for Transaction<'c, DB>where
DB: Database,
impl<'c, DB> Debug for Transaction<'c, DB>where
DB: Database,
Source§impl<'c, DB> Deref for Transaction<'c, DB>where
DB: Database,
impl<'c, DB> Deref for Transaction<'c, DB>where
DB: Database,
Source§impl<'c, DB> DerefMut for Transaction<'c, DB>where
DB: Database,
impl<'c, DB> DerefMut for Transaction<'c, DB>where
DB: Database,
Source§impl<'c, DB> Drop for Transaction<'c, DB>where
DB: Database,
impl<'c, DB> Drop for Transaction<'c, DB>where
DB: Database,
Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Any>
Available on (crate features postgres or mysql or mssql or sqlite or odbc) and crate feature any only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Any>
Available on (crate features
postgres or mysql or mssql or sqlite or odbc) and crate feature any only.type Database = Any
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<Any as Database>::QueryResult, AnyRow>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<<Any as Database>::QueryResult, AnyRow>, Error>>
Execute multiple queries and return the generated results as a stream
from each query, in a stream.
Source§fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<AnyRow>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<AnyRow>, Error>>
Execute the query and returns at most one row.
Source§fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
Prepare the SQL query, with parameter type information, to inspect the
type information about its parameters and results. Read more
Source§fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute the query and return the total number of rows affected.
Source§fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute multiple queries and return the rows affected from each query, in a stream.
Source§fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and return the generated results as a stream.
Source§fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
Execute the query and return all the generated results, collected into a
Vec.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Mssql>
Available on crate feature mssql only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Mssql>
Available on crate feature
mssql only.type Database = Mssql
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<Mssql as Database>::QueryResult, MssqlRow>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<<Mssql as Database>::QueryResult, MssqlRow>, Error>>
Execute multiple queries and return the generated results as a stream
from each query, in a stream.
Source§fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<MssqlRow>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<MssqlRow>, Error>>
Execute the query and returns at most one row.
Source§fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
Prepare the SQL query, with parameter type information, to inspect the
type information about its parameters and results. Read more
Source§fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute the query and return the total number of rows affected.
Source§fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute multiple queries and return the rows affected from each query, in a stream.
Source§fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and return the generated results as a stream.
Source§fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
Execute the query and return all the generated results, collected into a
Vec.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, MySql>
Available on crate feature mysql only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, MySql>
Available on crate feature
mysql only.type Database = MySql
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<MySql as Database>::QueryResult, MySqlRow>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<<MySql as Database>::QueryResult, MySqlRow>, Error>>
Execute multiple queries and return the generated results as a stream
from each query, in a stream.
Source§fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<MySqlRow>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<MySqlRow>, Error>>
Execute the query and returns at most one row.
Source§fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
Prepare the SQL query, with parameter type information, to inspect the
type information about its parameters and results. Read more
Source§fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute the query and return the total number of rows affected.
Source§fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute multiple queries and return the rows affected from each query, in a stream.
Source§fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and return the generated results as a stream.
Source§fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
Execute the query and return all the generated results, collected into a
Vec.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Odbc>
Available on crate feature odbc only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Odbc>
Available on crate feature
odbc only.type Database = Odbc
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<Odbc as Database>::QueryResult, OdbcRow>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<<Odbc as Database>::QueryResult, OdbcRow>, Error>>
Execute multiple queries and return the generated results as a stream
from each query, in a stream.
Source§fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<OdbcRow>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<OdbcRow>, Error>>
Execute the query and returns at most one row.
Source§fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
Prepare the SQL query, with parameter type information, to inspect the
type information about its parameters and results. Read more
Source§fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute the query and return the total number of rows affected.
Source§fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute multiple queries and return the rows affected from each query, in a stream.
Source§fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and return the generated results as a stream.
Source§fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
Execute the query and return all the generated results, collected into a
Vec.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Postgres>
Available on crate feature postgres only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Postgres>
Available on crate feature
postgres only.type Database = Postgres
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<Postgres as Database>::QueryResult, PgRow>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<<Postgres as Database>::QueryResult, PgRow>, Error>>
Execute multiple queries and return the generated results as a stream
from each query, in a stream.
Source§fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<PgRow>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<PgRow>, Error>>
Execute the query and returns at most one row.
Source§fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
Prepare the SQL query, with parameter type information, to inspect the
type information about its parameters and results. Read more
Source§fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute the query and return the total number of rows affected.
Source§fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute multiple queries and return the rows affected from each query, in a stream.
Source§fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and return the generated results as a stream.
Source§fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
Execute the query and return all the generated results, collected into a
Vec.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Sqlite>
Available on crate feature sqlite only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Sqlite>
Available on crate feature
sqlite only.type Database = Sqlite
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<Sqlite as Database>::QueryResult, SqliteRow>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<<Sqlite as Database>::QueryResult, SqliteRow>, Error>>
Execute multiple queries and return the generated results as a stream
from each query, in a stream.
Source§fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<SqliteRow>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<SqliteRow>, Error>>
Execute the query and returns at most one row.
Source§fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
't: 'e,
Prepare the SQL query, with parameter type information, to inspect the
type information about its parameters and results. Read more
Source§fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute the query and return the total number of rows affected.
Source§fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute multiple queries and return the rows affected from each query, in a stream.
Source§fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and return the generated results as a stream.
Source§fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
Execute the query and return all the generated results, collected into a
Vec.Auto Trait Implementations§
impl<'c, DB> Freeze for Transaction<'c, DB>
impl<'c, DB> !RefUnwindSafe for Transaction<'c, DB>
impl<'c, DB> Send for Transaction<'c, DB>
impl<'c, DB> Sync for Transaction<'c, DB>
impl<'c, DB> Unpin for Transaction<'c, DB>
impl<'c, DB> !UnwindSafe for Transaction<'c, DB>
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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