RustIO

Enum RustIO 

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

§

Right(A)

§

Wrong(T)

§

Value(A)

§

Empty()

§

Fut(LocalBoxFuture<'static, A>)

Trait Implementations§

Source§

impl<A, T> Lift<A, T> for RustIO<A, T>

Implementation of the Monad Lift.

Source§

fn of(a: A) -> Self

Pure value to create RustIO monad without side-effects.

Source§

fn at_some_point<F>(self, op: F) -> Self
where A: Clone, F: Clone + FnOnce(A) -> 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
where A: Clone, P: Clone + FnOnce() -> bool, F: Clone + FnOnce(A) -> 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
where A: Clone, P: Clone + FnOnce() -> bool, F: Clone + FnOnce(A) -> 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

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) -> Self
where 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

Join the LocalBoxFuture.

Source§

fn daemon<F: FnOnce(&A)>(self, op: F) -> Self

async consumer function that does not affect the current value of the monad.

Source§

fn lift(a: A) -> Self

Source§

fn from_func(f: fn() -> A) -> Self

Source§

fn from_option_func(f: fn() -> Option<A>) -> Self

Source§

fn from_result_func(f: fn() -> Result<A, T>) -> Self

Source§

fn from_option(a: Option<A>) -> Self

Source§

fn from_result(a: Result<A, T>) -> Self

Source§

fn merge<F: FnOnce(A, A) -> Self>(a: Self, b: Self, op: F) -> Self

Source§

fn get(self) -> A

Source§

fn failed(self) -> T

Source§

fn get_or_else(self, default: A) -> A

Source§

fn is_ok(&self) -> bool

Source§

fn is_failed(&self) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn map<F: FnOnce(A) -> A>(self, op: F) -> Self

Source§

fn map_error<F: FnOnce(T) -> T>(self, op: F) -> Self

Source§

fn flat_map<F: FnOnce(A) -> Self>(self, op: F) -> Self

Source§

fn when<P: FnOnce(&A) -> bool, F: FnOnce(A) -> A>( self, predicate: P, op: F, ) -> Self

Source§

fn when_rio<P: FnOnce(&A) -> bool, F: FnOnce(A) -> Self>( self, predicate: P, op: F, ) -> Self

Source§

fn zip<Z1: FnOnce() -> Self, Z2: FnOnce() -> Self, F: FnOnce(A, A) -> Self>( a: Z1, b: Z2, op: F, ) -> Self

Source§

fn filter<F: FnOnce(&A) -> bool>(self, op: F) -> Self

Source§

fn fold<F: FnOnce(A) -> A>(self, default: A, op: F) -> Self

Source§

fn recover<F: FnOnce() -> A>(self, op: F) -> Self

Source§

fn recover_with<F: FnOnce() -> Self>(self, op: F) -> Self

Source§

fn delay(self, time: Duration) -> Self

Source§

fn peek<F: FnOnce(&A)>(self, op: F) -> Self

Source§

fn on_error<F: FnOnce(&T)>(self, op: F) -> Self

Source§

fn on_success<F: FnOnce(&A)>(self, op: F) -> Self

Auto Trait Implementations§

§

impl<A, T> Freeze for RustIO<A, T>
where A: Freeze, T: Freeze,

§

impl<A, T> !RefUnwindSafe for RustIO<A, T>

§

impl<A, T> !Send for RustIO<A, T>

§

impl<A, T> !Sync for RustIO<A, T>

§

impl<A, T> Unpin for RustIO<A, T>
where A: Unpin, T: Unpin,

§

impl<A, T> !UnwindSafe for RustIO<A, T>

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, 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