pub enum TransactionIsolation {
ReadUncommitted,
ReadCommitted,
RepeatableRead,
Serializable,
}Expand description
SQL 事务隔离级别。
对应 SQL 标准的四种隔离级别,不同后端的 SQL 语法略有差异。
Variants§
ReadUncommitted
读未提交(最低隔离级别,允许脏读)
ReadCommitted
读已提交(禁止脏读,允许不可重复读)
RepeatableRead
可重复读(禁止不可重复读,允许幻读)
Serializable
串行化(最高隔离级别,完全隔离)
Implementations§
Source§impl TransactionIsolation
impl TransactionIsolation
Sourcepub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
返回隔离级别的中文描述。
Sourcepub fn strictness(&self) -> u8
pub fn strictness(&self) -> u8
返回隔离级别的严格程度排序值(0=最低,3=最高)。
Sourcepub fn set_session_sql(&self, backend: AnyBackend) -> String
pub fn set_session_sql(&self, backend: AnyBackend) -> String
生成设置当前会话隔离级别的 SQL 语句。
不同后端语法略有差异:
- MySQL:
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED - PostgreSQL:
SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED - SQLite: 不支持(SQLite 始终使用 SERIALIZABLE),返回空字符串
Sourcepub fn set_transaction_sql(&self, backend: AnyBackend) -> String
pub fn set_transaction_sql(&self, backend: AnyBackend) -> String
生成设置下一事务隔离级别的 SQL 语句。
- MySQL:
SET TRANSACTION ISOLATION LEVEL READ COMMITTED - PostgreSQL:
SET TRANSACTION ISOLATION LEVEL READ COMMITTED - SQLite: 不支持,返回空字符串
Sourcepub fn query_sql(&self, backend: AnyBackend) -> String
pub fn query_sql(&self, backend: AnyBackend) -> String
生成查询当前隔离级别的 SQL 语句。
- MySQL:
SELECT @@transaction_isolation - PostgreSQL:
SHOW transaction_isolation - SQLite: 不支持,返回空字符串
Trait Implementations§
Source§impl Clone for TransactionIsolation
impl Clone for TransactionIsolation
Source§fn clone(&self) -> TransactionIsolation
fn clone(&self) -> TransactionIsolation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for TransactionIsolation
Source§impl Debug for TransactionIsolation
impl Debug for TransactionIsolation
Source§impl Default for TransactionIsolation
impl Default for TransactionIsolation
Source§fn default() -> TransactionIsolation
fn default() -> TransactionIsolation
Returns the “default value” for a type. Read more
Source§impl Display for TransactionIsolation
impl Display for TransactionIsolation
impl Eq for TransactionIsolation
Source§impl Hash for TransactionIsolation
impl Hash for TransactionIsolation
Source§impl PartialEq for TransactionIsolation
impl PartialEq for TransactionIsolation
impl StructuralPartialEq for TransactionIsolation
Auto Trait Implementations§
impl Freeze for TransactionIsolation
impl RefUnwindSafe for TransactionIsolation
impl Send for TransactionIsolation
impl Sync for TransactionIsolation
impl Unpin for TransactionIsolation
impl UnsafeUnpin for TransactionIsolation
impl UnwindSafe for TransactionIsolation
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 more