pub struct TransactionScope<'a> { /* private fields */ }Expand description
Scope-based transaction manager for nested transactions.
Provides a stack-based interface for managing nested transactions.
Each begin() pushes a new transaction, and commit() or rollback()
pops and finalizes it.
Implementations§
Source§impl<'a> TransactionScope<'a>
impl<'a> TransactionScope<'a>
Sourcepub fn new(history: &'a mut HistoryManager) -> Self
pub fn new(history: &'a mut HistoryManager) -> Self
Create a new transaction scope.
Sourcepub fn execute(&mut self, cmd: Box<dyn UndoableCmd>) -> CommandResult
pub fn execute(&mut self, cmd: Box<dyn UndoableCmd>) -> CommandResult
Execute a command in the current transaction.
If no transaction is active, the command is executed and added directly to history.
§Errors
Returns error if the command fails.
Sourcepub fn commit(&mut self) -> CommandResult
pub fn commit(&mut self) -> CommandResult
Commit the current transaction.
If nested, the committed transaction is added to the parent. If at top level, it’s added to history.
§Errors
Returns error if no transaction is active.
Sourcepub fn rollback(&mut self) -> CommandResult
pub fn rollback(&mut self) -> CommandResult
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TransactionScope<'a>
impl<'a> !RefUnwindSafe for TransactionScope<'a>
impl<'a> Send for TransactionScope<'a>
impl<'a> Sync for TransactionScope<'a>
impl<'a> Unpin for TransactionScope<'a>
impl<'a> UnsafeUnpin for TransactionScope<'a>
impl<'a> !UnwindSafe for TransactionScope<'a>
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