pub enum AnyTransaction {
MySql(Transaction),
Postgres(Transaction),
}Expand description
两种后端事务的统一句柄。
由 AnyDatabase::begin 或 crate::action::ActionContext::begin_transaction
创建;TableQuery 的 *_in_tx 系列方法按变体分派到对应后端。
Variants§
Implementations§
Source§impl AnyTransaction
impl AnyTransaction
Sourcepub fn backend(&self) -> BackendKind
pub fn backend(&self) -> BackendKind
返回事务所属后端。
Sourcepub fn as_mysql(&mut self) -> Option<&mut Transaction>
pub fn as_mysql(&mut self) -> Option<&mut Transaction>
当持有 MySQL 事务时返回其可变引用。
Sourcepub fn as_postgres(&mut self) -> Option<&mut Transaction>
pub fn as_postgres(&mut self) -> Option<&mut Transaction>
当持有 PostgreSQL 事务时返回其可变引用。
Sourcepub async fn savepoint(&mut self, name: &str) -> Result<(), DbError>
pub async fn savepoint(&mut self, name: &str) -> Result<(), DbError>
在当前事务内创建保存点(与后端无关的封装)。
PostgreSQL 走其后端原生 SAVEPOINT;MySQL 同样支持保存点语法,这里用
校验过的标识符拼接控制语句。name 必须是 ASCII 标识符(字母/下划线开头,
仅字母/数字/下划线),非法名称返回 DbError::InvalidArgument。
Auto Trait Implementations§
impl !RefUnwindSafe for AnyTransaction
impl !UnwindSafe for AnyTransaction
impl Forget for AnyTransaction
impl Freeze for AnyTransaction
impl Move for AnyTransaction
impl Send for AnyTransaction
impl Sync for AnyTransaction
impl Unpin for AnyTransaction
impl UnsafeUnpin for AnyTransaction
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> 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