TransactionContext

Struct TransactionContext 

Source
pub struct TransactionContext<'g> { /* private fields */ }
Expand description

Orchestrates transactions across graph mutations, change logging, and rollback

Implementations§

Source§

impl<'g> TransactionContext<'g>

Source

pub fn new(graph: &'g mut DependencyGraph) -> Self

Create a new transaction context for the given graph

Source

pub fn with_max_size(graph: &'g mut DependencyGraph, max_size: usize) -> Self

Create a transaction context with custom max transaction size

Source

pub fn begin(&mut self) -> Result<TransactionId, TransactionError>

Begin a new transaction

§Returns

The ID of the newly created transaction

§Errors

Returns AlreadyActive if a transaction is already in progress

Source

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:

  1. We control the lifetime of both the graph and change_log
  2. The editor’s lifetime is tied to the TransactionContext
  3. We ensure no aliasing occurs
Source

pub fn commit(&mut self) -> Result<TransactionId, TransactionError>

Commit the current transaction

§Returns

The ID of the committed transaction

§Errors

Returns NoActiveTransaction if no transaction is active

Source

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

Source

pub fn savepoint(&mut self, name: &str) -> Result<(), TransactionError>

Add a named savepoint to the current transaction

§Arguments
  • name - Name for the savepoint
§Errors

Returns NoActiveTransaction if no transaction is active

Source

pub fn rollback_to_savepoint( &mut self, name: &str, ) -> Result<(), TransactionError>

Rollback to a named savepoint

§Arguments
  • name - Name of the savepoint to rollback to
§Errors

Returns NoActiveTransaction if no transaction is active Returns SavepointNotFound if the savepoint doesn’t exist Returns RollbackFailed if the rollback operation fails

Source

pub fn is_active(&self) -> bool

Check if a transaction is currently active

Source

pub fn active_id(&self) -> Option<TransactionId>

Get the ID of the active transaction if any

Source

pub fn change_count(&self) -> usize

Get the current size of the change log

Source

pub fn change_log(&self) -> &ChangeLog

Get reference to the change log (for testing/debugging)

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,