pub enum TransactionMode {
Default,
Deferred,
Immediate,
Exclusive,
}Expand description
How a transaction acquires write locks.
Orthogonal to IsolationLevel: an isolation level describes what
anomalies a transaction can observe; a mode describes when the
transaction acquires its locks.
Only SQLite (and SQLite-compatible engines) currently expose this dimension to clients:
Default→ whatever the driver picks. For SQLite that isBEGIN(DEFERRED) today; for a future driver it may not be — e.g. Turso under MVCC plans to default toBEGIN CONCURRENT.Deferred→BEGIN(DEFERRED): explicit deferred locking. Identical toDefaulton plain SQLite; on a driver whose default is not deferred (Turso MVCC), this is how the caller opts out of that default.Immediate→BEGIN IMMEDIATE: write lock acquired up front, so a later write inside the transaction cannot fail withSQLITE_BUSY.Exclusive→BEGIN EXCLUSIVE: exclusive lock held for the lifetime of the transaction; no other connection — reader or writer — can make progress against the database file.
Drivers that do not implement a given mode return
Error::unsupported_feature when
the transaction starts. Future drivers may extend this enum (e.g. a
Turso Concurrent variant for BEGIN CONCURRENT under MVCC).
Variants§
Default
The driver’s natural default. May differ from
Deferred on drivers that prefer a different
locking strategy (e.g. Turso MVCC → BEGIN CONCURRENT).
Deferred
Explicit deferred locking. SQLite → BEGIN (DEFERRED). Use this
to override a driver whose Default is not deferred.
Immediate
Acquire a write lock when the transaction begins. SQLite →
BEGIN IMMEDIATE. Rejected by drivers without an equivalent.
Exclusive
Hold an exclusive lock for the entire transaction. SQLite →
BEGIN EXCLUSIVE. Rejected by drivers without an equivalent.
Trait Implementations§
Source§impl Clone for TransactionMode
impl Clone for TransactionMode
Source§fn clone(&self) -> TransactionMode
fn clone(&self) -> TransactionMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TransactionMode
impl Debug for TransactionMode
Source§impl Default for TransactionMode
impl Default for TransactionMode
Source§fn default() -> TransactionMode
fn default() -> TransactionMode
Source§impl PartialEq for TransactionMode
impl PartialEq for TransactionMode
impl Copy for TransactionMode
impl Eq for TransactionMode
impl StructuralPartialEq for TransactionMode
Auto Trait Implementations§
impl Freeze for TransactionMode
impl RefUnwindSafe for TransactionMode
impl Send for TransactionMode
impl Sync for TransactionMode
impl Unpin for TransactionMode
impl UnsafeUnpin for TransactionMode
impl UnwindSafe for TransactionMode
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.