1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
use Operation;
/// SQL transaction isolation levels.
///
/// Not all backends support all levels. The driver returns an error if an
/// unsupported level is requested.
///
/// # Examples
///
/// ```
/// use toasty_core::driver::operation::IsolationLevel;
///
/// let level = IsolationLevel::Serializable;
/// assert_eq!(level, IsolationLevel::Serializable);
/// ```
/// 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`](Self::Default) → whatever the driver picks. For SQLite
/// that is `BEGIN` (DEFERRED) today; for a future driver it may not
/// be — e.g. Turso under MVCC plans to default to `BEGIN CONCURRENT`.
/// * [`Deferred`](Self::Deferred) → `BEGIN` (DEFERRED): explicit
/// deferred locking. Identical to `Default` on plain SQLite; on a
/// driver whose default is *not* deferred (Turso MVCC), this is how
/// the caller opts out of that default.
/// * [`Immediate`](Self::Immediate) → `BEGIN IMMEDIATE`: write lock
/// acquired up front, so a later write inside the transaction cannot
/// fail with `SQLITE_BUSY`.
/// * [`Exclusive`](Self::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`](crate::Error::unsupported_feature) when
/// the transaction starts. Future drivers may extend this enum (e.g. a
/// Turso `Concurrent` variant for `BEGIN CONCURRENT` under MVCC).
/// A transaction lifecycle operation.
///
/// Covers the full transaction lifecycle: begin, commit, rollback, and
/// savepoint management. Convert to [`Operation`] with `.into()`.
///
/// # Examples
///
/// ```
/// use toasty_core::driver::operation::{Transaction, Operation};
///
/// // Start a default transaction
/// let op: Operation = Transaction::start().into();
///
/// // Commit
/// let op: Operation = Transaction::Commit.into();
/// assert!(op.is_transaction_commit());
/// ```