Trait transaction::Transaction [] [src]

#[must_use]
pub trait Transaction { type Ctx; type Item; type Err; fn run(&self, ctx: &mut Self::Ctx) -> Result<Self::Item, Self::Err>; fn boxed<'a>(
        self
    ) -> Box<Transaction<Ctx = Self::Ctx, Item = Self::Item, Err = Self::Err> + 'a>
    where
        Self: Sized + 'a
, { ... } fn then<F, B, Tx2>(self, f: F) -> Then<Self, F, Tx2>
    where
        Tx2: IntoTransaction<Self::Ctx, Item = B, Err = Self::Err>,
        F: Fn(Result<Self::Item, Self::Err>) -> Tx2,
        Self: Sized
, { ... } fn map<F, B>(self, f: F) -> Map<Self, F>
    where
        F: Fn(Self::Item) -> B,
        Self: Sized
, { ... } fn and_then<F, B>(self, f: F) -> AndThen<Self, F, B>
    where
        B: IntoTransaction<Self::Ctx, Err = Self::Err>,
        F: Fn(Self::Item) -> B,
        Self: Sized
, { ... } fn map_err<F, B>(self, f: F) -> MapErr<Self, F>
    where
        F: Fn(Self::Err) -> B,
        Self: Sized
, { ... } fn or_else<F, B>(self, f: F) -> OrElse<Self, F, B>
    where
        B: IntoTransaction<Self::Ctx, Item = Self::Item>,
        F: Fn(Self::Err) -> B,
        Self: Sized
, { ... } fn abort<T, F>(self, f: F) -> Abort<Self, T, F>
    where
        F: Fn(Self::Item) -> Self::Err,
        Self: Sized
, { ... } fn try_abort<F, B>(self, f: F) -> TryAbort<Self, F, B>
    where
        F: Fn(Self::Item) -> Result<B, Self::Err>,
        Self: Sized
, { ... } fn recover<T, F>(self, f: F) -> Recover<Self, T, F>
    where
        F: Fn(Self::Err) -> Self::Item,
        Self: Sized
, { ... } fn try_recover<F, B>(self, f: F) -> TryRecover<Self, F, B>
    where
        F: Fn(Self::Err) -> Result<Self::Item, B>,
        Self: Sized
, { ... } fn join<B>(self, b: B) -> Join<Self, B::Tx>
    where
        B: IntoTransaction<Self::Ctx, Err = Self::Err>,
        Self: Sized
, { ... } fn join3<B, C>(self, b: B, c: C) -> Join3<Self, B::Tx, C::Tx>
    where
        B: IntoTransaction<Self::Ctx, Err = Self::Err>,
        C: IntoTransaction<Self::Ctx, Err = Self::Err>,
        Self: Sized
, { ... } fn join4<B, C, D>(
        self,
        b: B,
        c: C,
        d: D
    ) -> Join4<Self, B::Tx, C::Tx, D::Tx>
    where
        B: IntoTransaction<Self::Ctx, Err = Self::Err>,
        C: IntoTransaction<Self::Ctx, Err = Self::Err>,
        D: IntoTransaction<Self::Ctx, Err = Self::Err>,
        Self: Sized
, { ... } fn branch(self) -> BranchBuilder<Self>
    where
        Self: Sized
, { ... } fn branch3(self) -> Branch3Builder<Self>
    where
        Self: Sized
, { ... } fn branch4(self) -> Branch4Builder<Self>
    where
        Self: Sized
, { ... } }

An abstract transaction. Transactions sharing the same Ctx can be composed with combinators. When the transaction return an error, it means the transaction is failed. Some runners may abort the transaction and the other may retry the computation. Thus all the computation should be idempotent (of cause, except operations using context). Note that this transaction is not executed until it is run.

Associated Types

The contxt type (i.e. transaction type) of the transaction

The return type of the transaction

The error type of the transaction

Required Methods

Run the transaction. This will called by transaction runner rather than user by hand.

Provided Methods

Box the transaction

Take the previous result of computation and do another computation

Transform the previous successful value

Take the previous successful value of computation and do another computation

Transform the previous error value

Take the previous error value of computation and do another computation. This may be used falling back

Take the previous successfull value of computation and abort the transaction.

Try to abort the transaction

Recover from an error

Try to recover from an error

join 2 indepndant transactions

join 3 indepndant transactions

join 4 indepndant transactions

branch builder

3 branch builder

4 branch builder

Implementors