pub enum RustIO<A, T> {
Right(A),
Wrong(T),
Value(A),
Empty(),
Fut(LocalBoxFuture<'static, A>),
}Expand description
Data structure to be used as the monad to be implemented as Lift RustIO monad can have the list of possible states.
Variants§
Trait Implementations§
Source§impl<A, T> Lift<A, T> for RustIO<A, T>
Implementation of the Monad Lift.
impl<A, T> Lift<A, T> for RustIO<A, T>
Implementation of the Monad Lift.
Source§fn at_some_point<F>(self, op: F) -> Self
fn at_some_point<F>(self, op: F) -> Self
Returns an effect that ignores errors and runs repeatedly until it [at_some_point] succeeds We mark A type as Clone since we need a clone of the value for each iteration in the loop. In case you need a backoff between iterations, or a escape clause, you can use [until] or [while] [at_some_point] operator conditions.
Source§fn at_some_point_while<P, F>(self, predicate: P, op: F) -> Self
fn at_some_point_while<P, F>(self, predicate: P, op: F) -> Self
Retry pattern of a task while a predicate condition is false
Source§fn at_some_point_until<P, F>(self, predicate: P, op: F) -> Self
fn at_some_point_until<P, F>(self, predicate: P, op: F) -> Self
Retry pattern of a task while a predicate condition is true
Source§fn parallel<Task: FnOnce() -> Self, F: FnOnce(Vec<A>) -> Self>(
tasks: Vec<Task>,
op: F,
) -> Self
fn parallel<Task: FnOnce() -> Self, F: FnOnce(Vec<A>) -> Self>( tasks: Vec<Task>, op: F, ) -> Self
Operator to run every task in the Vector asynchronously using async. After we create the list of Futures, we use join_all to run all futures in parallel. Once all of them are finished, we invoke the passed function with [Vector] as input param
Source§fn fork<F>(self, op: F) -> Selfwhere
A: 'static,
F: 'static + FnOnce(A) -> A,
fn fork<F>(self, op: F) -> Selfwhere
A: 'static,
F: 'static + FnOnce(A) -> A,
It run the execution of the task in another green thread We use type Fut to wrap the LocalBoxFuture which it contains the output of the function execution.
Source§fn join(self) -> Self
fn join(self) -> Self
Join the LocalBoxFuture.
Source§fn daemon<F: FnOnce(&A)>(self, op: F) -> Self
fn daemon<F: FnOnce(&A)>(self, op: F) -> Self
async consumer function that does not affect the current value of the monad.