pub struct Transaction { /* private fields */ }Expand description
A transaction on one Turso connection.
Created with Database::begin or
Database::begin_with_mode. Nested
transactions (txn.begin()) are SAVEPOINTs on the same connection.
While a nested transaction is open it is the only one that may run
statements, begin, commit or roll back; its parents fail with
Error::Misuse until it is finished or dropped. Dropping an unfinished
transaction rolls it back: a top-level transaction discards its
connection, a nested one is rolled back to its savepoint before the
parent runs its next statement.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub async fn commit(self) -> Result<()>
pub async fn commit(self) -> Result<()>
Commits the transaction — COMMIT, or RELEASE SAVEPOINT when
nested.
§Errors
Returns Error::Misuse when a nested transaction is still open or
the transaction can no longer act, in which case it is rolled back;
Error::Turso when the commit fails — an MVCC write conflict
surfaces here with ErrorKind::Busy.
Sourcepub async fn rollback(self) -> Result<()>
pub async fn rollback(self) -> Result<()>
Rolls the transaction back — ROLLBACK, or ROLLBACK TO SAVEPOINT
when nested.
§Errors
Returns Error::Misuse when a nested transaction is still open or
the transaction can no longer act, in which case it is still rolled
back; Error::Turso when the rollback fails.
Trait Implementations§
Source§impl ConnectionTrait for &Transaction
impl ConnectionTrait for &Transaction
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
statement: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
statement: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
;-separated statements without parameters.Source§impl ConnectionTrait for Transaction
impl ConnectionTrait for Transaction
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
statement: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
statement: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
;-separated statements without parameters.Source§impl Debug for Transaction
impl Debug for Transaction
Source§impl Drop for Transaction
impl Drop for Transaction
Source§impl StreamTrait for Transaction
impl StreamTrait for Transaction
Source§impl TransactionTrait for Transaction
impl TransactionTrait for Transaction
Source§fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
BEGIN DEFERRED, or a savepoint when called on a
transaction. Read moreSource§fn begin_with_mode<'life0, 'async_trait>(
&'life0 self,
_mode: TransactionMode,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_with_mode<'life0, 'async_trait>(
&'life0 self,
_mode: TransactionMode,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for Transaction
impl !UnwindSafe for Transaction
impl Freeze for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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