pub struct TransactionContext<'g> { /* private fields */ }Expand description
Orchestrates transactions across graph mutations, change logging, and rollback
Implementations§
Source§impl<'g> TransactionContext<'g>
impl<'g> TransactionContext<'g>
Sourcepub fn new(graph: &'g mut DependencyGraph) -> Self
pub fn new(graph: &'g mut DependencyGraph) -> Self
Create a new transaction context for the given graph
Sourcepub fn with_max_size(graph: &'g mut DependencyGraph, max_size: usize) -> Self
pub fn with_max_size(graph: &'g mut DependencyGraph, max_size: usize) -> Self
Create a transaction context with custom max transaction size
Sourcepub fn begin(&mut self) -> Result<TransactionId, TransactionError>
pub fn begin(&mut self) -> Result<TransactionId, TransactionError>
Sourcepub fn editor(&mut self) -> VertexEditor<'_>
pub fn editor(&mut self) -> VertexEditor<'_>
Create an editor that logs changes to this context
§Safety
This uses unsafe code to work around the borrow checker. It’s safe because:
- We control the lifetime of both the graph and change_log
- The editor’s lifetime is tied to the TransactionContext
- We ensure no aliasing occurs
Sourcepub fn commit(&mut self) -> Result<TransactionId, TransactionError>
pub fn commit(&mut self) -> Result<TransactionId, TransactionError>
Sourcepub fn rollback(&mut self) -> Result<(), TransactionError>
pub fn rollback(&mut self) -> Result<(), TransactionError>
Rollback the current transaction
§Errors
Returns NoActiveTransaction if no transaction is active
Returns RollbackFailed if the rollback operation fails
Sourcepub fn rollback_to_savepoint(
&mut self,
name: &str,
) -> Result<(), TransactionError>
pub fn rollback_to_savepoint( &mut self, name: &str, ) -> Result<(), TransactionError>
Sourcepub fn active_id(&self) -> Option<TransactionId>
pub fn active_id(&self) -> Option<TransactionId>
Get the ID of the active transaction if any
Sourcepub fn change_count(&self) -> usize
pub fn change_count(&self) -> usize
Get the current size of the change log
Sourcepub fn change_log(&self) -> &ChangeLog
pub fn change_log(&self) -> &ChangeLog
Get reference to the change log (for testing/debugging)
Sourcepub fn clear_change_log(&mut self)
pub fn clear_change_log(&mut self)
Clear the change log (useful between transactions)
Auto Trait Implementations§
impl<'g> Freeze for TransactionContext<'g>
impl<'g> RefUnwindSafe for TransactionContext<'g>
impl<'g> Send for TransactionContext<'g>
impl<'g> Sync for TransactionContext<'g>
impl<'g> Unpin for TransactionContext<'g>
impl<'g> !UnwindSafe for TransactionContext<'g>
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> 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