Struct mem_query::transaction::Transaction[][src]

#[must_use]
pub struct Transaction<'a, Root: 'a + ?Sized, Undo = (), E = Infallible> { /* fields omitted */ }
Expand description

A transaction holds exclusive access to some root object and lets you apply RevertableOps to it. If any of these operations fail, the prior ones are immediately reverted and further operation requests are ignored. The error will be returned from commit().

Implementations

impl<'a, T: 'a + ?Sized> Transaction<'a, T>[src]

pub fn start(root: &'a mut T) -> Self[src]

Start a new transaction protecting the object root

impl<'a, Root: ?Sized + 'a, Undo: UndoLog<Root>, E> Transaction<'a, Root, Undo, E>[src]

pub fn commit(self) -> Result<(), E>[src]

Discard the undo log, and return any error that occurred.

pub fn revert(self)[src]

Process the undo log to return the root to its original state. Discards errors.

pub fn subtransaction<SubRoot, SubUndo, AccessFn, BodyFn, SubErr>(
    self,
    access: AccessFn,
    body: BodyFn
) -> Transaction<'a, Root, (SubUndoLog<AccessFn, SubUndo, SubRoot>, Undo), Either<SubErr, E>> where
    AccessFn: Accessor<Root, Dest = SubRoot>,
    SubRoot: ?Sized,
    BodyFn: FnOnce(Transaction<'_, SubRoot, ()>) -> Transaction<'_, SubRoot, SubUndo, SubErr>,
    SubUndo: UndoLog<SubRoot>, 
[src]

Run a transaction on an object accessible from the root.

pub fn apply<Op: RevertableOp<Root>>(
    self,
    op: Op
) -> Transaction<'a, Root, (Op::Log, Undo), Either<Op::Err, E>>
[src]

Apply a RevertableOp

pub fn apply_multi<Op: RevertableOp<Root>>(
    self,
    ops: impl IntoIterator<Item = Op>
) -> Transaction<'a, Root, (Vec<Op::Log>, Undo), Either<Op::Err, E>>
[src]

Apply several instances of the same RevertableOp. The iterator will stop as soon as one of the operations fails.

pub fn into_undo_log(self) -> Result<Undo, E>[src]

Allows a Transaction to be used within the implementation of a RevertableOp.

Auto Trait Implementations

impl<'a, Root: ?Sized, Undo, E> RefUnwindSafe for Transaction<'a, Root, Undo, E> where
    E: RefUnwindSafe,
    Root: RefUnwindSafe,
    Undo: RefUnwindSafe

impl<'a, Root: ?Sized, Undo, E> Send for Transaction<'a, Root, Undo, E> where
    E: Send,
    Root: Send,
    Undo: Send

impl<'a, Root: ?Sized, Undo, E> Sync for Transaction<'a, Root, Undo, E> where
    E: Sync,
    Root: Sync,
    Undo: Sync

impl<'a, Root: ?Sized, Undo, E> Unpin for Transaction<'a, Root, Undo, E> where
    E: Unpin,
    Undo: Unpin

impl<'a, Root, Undo = (), E = Infallible> !UnwindSafe for Transaction<'a, Root, Undo, E>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> Everything for T where
    T: ?Sized
[src]