pub struct Transaction<'c, DB: Database> { /* private fields */ }Expand description
An instrumented transaction, from Pool::begin or
Connection::begin. Run queries on &mut transaction. Like sqlx’s,
dropping it without committing rolls it back, but that rollback isn’t
recorded. It dereferences to sqlx’s Transaction.
Implementations§
Trait Implementations§
Source§impl<DB: Database> Debug for Transaction<'_, DB>
impl<DB: Database> Debug for Transaction<'_, DB>
Source§impl<'c, DB: Database> Deref for Transaction<'c, DB>
impl<'c, DB: Database> Deref for Transaction<'c, DB>
Source§type Target = Transaction<'c, DB>
type Target = Transaction<'c, DB>
The resulting type after dereferencing.
Source§fn deref(&self) -> &Transaction<'c, DB>
fn deref(&self) -> &Transaction<'c, DB>
Dereferences the value.
Source§impl<'c, DB: Database> DerefMut for Transaction<'c, DB>
impl<'c, DB: Database> DerefMut for Transaction<'c, DB>
Source§fn deref_mut(&mut self) -> &mut Transaction<'c, DB>
fn deref_mut(&mut self) -> &mut Transaction<'c, DB>
Mutably dereferences the value.
Source§impl<'t, DB> Executor<'t> for &'t mut Transaction<'_, DB>
impl<'t, DB> Executor<'t> for &'t mut Transaction<'_, DB>
type Database = DB
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<DB as Database>::QueryResult, <DB as Database>::Row>, Error>>where
E: 'q + Execute<'q, DB>,
't: 'e,
fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<DB as Database>::QueryResult, <DB as Database>::Row>, Error>>where
E: 'q + Execute<'q, DB>,
't: 'e,
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<DB::Row>, Error>>where
E: 'q + Execute<'q, DB>,
't: 'e,
fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<DB::Row>, Error>>where
E: 'q + Execute<'q, DB>,
't: 'e,
Execute the query and returns at most one row.
Source§fn prepare_with<'e>(
self,
sql: SqlStr,
parameters: &'e [DB::TypeInfo],
) -> BoxFuture<'e, Result<DB::Statement, Error>>where
't: 'e,
fn prepare_with<'e>(
self,
sql: SqlStr,
parameters: &'e [DB::TypeInfo],
) -> BoxFuture<'e, Result<DB::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>(
self,
query: E,
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
fn execute<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
Execute the query and return the total number of rows affected.
Source§fn execute_many<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
fn execute_many<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
Execute multiple queries and return the rows affected from each query, in a stream.
Source§fn fetch<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
fn fetch<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
Execute the query and return the generated results as a stream.
Source§fn fetch_all<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
fn fetch_all<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
Execute the query and return all the generated results, collected into a
Vec.Auto Trait Implementations§
impl<'c, DB> !RefUnwindSafe for Transaction<'c, DB>
impl<'c, DB> !UnwindSafe for Transaction<'c, DB>
impl<'c, DB> Freeze for Transaction<'c, DB>where
Transaction<'c, DB>: Freeze,
impl<'c, DB> Send for Transaction<'c, DB>where
Transaction<'c, DB>: Send,
impl<'c, DB> Sync for Transaction<'c, DB>where
Transaction<'c, DB>: Sync,
impl<'c, DB> Unpin for Transaction<'c, DB>where
Transaction<'c, DB>: Unpin,
impl<'c, DB> UnsafeUnpin for Transaction<'c, DB>where
Transaction<'c, DB>: UnsafeUnpin,
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
impl<R> CryptoRng for R
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> ⓘ
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 moreimpl<R> RngCore for Rwhere
R: Rng,
Source§impl<R> RngExt for R
impl<R> RngExt for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
Return a random value via the
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more