Expand description
Transaction handle abstraction.
Decouples transaction capabilities from DbContext so callers can hold a
typed handle (Box<dyn ITransaction>) returned by
DbContext::begin_transaction(). The handle exposes commit / rollback
(which consume it), savepoint operations, isolation level control, and a
connection() accessor used internally by save_changes() to reuse the
ambient transaction’s connection.
§Two control modes
- Manual —
let txn = ctx.begin_transaction().await?; ... txn.commit().await?;The handle is returned without registering an ambient;save_changes()will self-manage its own transaction. Use this when you need the handle for explicit savepoint / isolation control. - Scoped —
ctx.use_transaction(|ctx| Box::pin(async move { ... })).await?Registers the handle as ambient;save_changes()calls inside the closure reuse the same transaction. Commits onOk, rolls back onErr.
Structs§
- DbTransaction
- Default
ITransactionimplementation wrapping anIAsyncConnection.
Traits§
- ITransaction
- Transaction handle abstracting the Priority 2 connection-level transaction methods.