#[non_exhaustive]pub struct TransactionOptions {
pub isolation: Option<IsolationLevel>,
pub read_only: bool,
pub deferrable: bool,
}Expand description
PostgreSQL 事务属性(Phase B)。
与 IsolationLevel 组合使用:isolation 为 None 时不发
SET TRANSACTION ISOLATION LEVEL,沿用服务端默认(通常是 READ COMMITTED)。
标注 #[non_exhaustive]:未来新增事务属性不构成破坏性变更;跨 crate 请用
TransactionOptions::default / TransactionOptions::new 加链式 setter 构造。
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.isolation: Option<IsolationLevel>隔离级别;None 表示沿用服务端默认。
read_only: bool是否声明为只读事务(READ ONLY)。只读事务内写入由服务端拒绝(SQLSTATE 25006)。
deferrable: bool是否声明 DEFERRABLE(只对 SERIALIZABLE READ ONLY 事务有实际意义)。
Implementations§
Source§impl TransactionOptions
impl TransactionOptions
Sourcepub fn with_isolation(self, isolation: IsolationLevel) -> Self
pub fn with_isolation(self, isolation: IsolationLevel) -> Self
设置隔离级别(链式)。
Sourcepub fn with_read_only(self, read_only: bool) -> Self
pub fn with_read_only(self, read_only: bool) -> Self
设置只读属性(链式)。
Sourcepub fn with_deferrable(self, deferrable: bool) -> Self
pub fn with_deferrable(self, deferrable: bool) -> Self
设置 DEFERRABLE 属性(链式)。
Trait Implementations§
Source§impl Clone for TransactionOptions
impl Clone for TransactionOptions
impl Copy for TransactionOptions
Source§impl Debug for TransactionOptions
impl Debug for TransactionOptions
Source§impl Default for TransactionOptions
impl Default for TransactionOptions
impl Eq for TransactionOptions
Source§impl PartialEq for TransactionOptions
impl PartialEq for TransactionOptions
impl StructuralPartialEq for TransactionOptions
Auto Trait Implementations§
impl Forget for TransactionOptions
impl Freeze for TransactionOptions
impl Move for TransactionOptions
impl RefUnwindSafe for TransactionOptions
impl Send for TransactionOptions
impl Sync for TransactionOptions
impl Unpin for TransactionOptions
impl UnsafeUnpin for TransactionOptions
impl UnwindSafe for TransactionOptions
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<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