Skip to main content

Effect

Enum Effect 

Source
pub enum Effect<M> {
Show 17 variants None, Task { id: EffectId, run: TaskFn<M>, }, RegisteredTask { id: EffectId, }, EnvTask { id: EffectId, run: EnvTaskFn<M>, }, RegisteredEnvTask { id: EffectId, }, RegisteredRun { id: EffectId, }, Batch(Vec<Effect<M>>), Cancellable { id: EffectId, cancel_in_flight: bool, inner: Box<Effect<M>>, }, Debounce { id: EffectId, duration: Duration, inner: Box<Effect<M>>, }, Throttle { id: EffectId, duration: Duration, latest: bool, inner: Box<Effect<M>>, }, Provide { env: Environment, inner: Box<Effect<M>>, }, Retry { attempts: u32, inner: Box<Effect<M>>, }, Timeout { duration: Duration, inner: Box<Effect<M>>, }, Sequence(Vec<Effect<M>>), Race(Vec<Effect<M>>), Catch { inner: Box<Effect<M>>, recover: fn(EffectError) -> Effect<M>, }, Cancel { id: EffectId, },
}
Expand description

Pure effect descriptions — interpreted only in runtime.rs.

Variants§

§

None

§

Task

Fields

§run: TaskFn<M>
§

RegisteredTask

Fields

§

EnvTask

Fields

§run: EnvTaskFn<M>
§

RegisteredEnvTask

Fields

§

RegisteredRun

Fields

§

Batch(Vec<Effect<M>>)

§

Cancellable

Fields

§cancel_in_flight: bool
§inner: Box<Effect<M>>
§

Debounce

Fields

§duration: Duration
§inner: Box<Effect<M>>
§

Throttle

Fields

§duration: Duration
§latest: bool
§inner: Box<Effect<M>>
§

Provide

Fields

§inner: Box<Effect<M>>
§

Retry

Fields

§attempts: u32
§inner: Box<Effect<M>>
§

Timeout

Fields

§duration: Duration
§inner: Box<Effect<M>>
§

Sequence(Vec<Effect<M>>)

§

Race(Vec<Effect<M>>)

§

Catch

Fields

§inner: Box<Effect<M>>
§recover: fn(EffectError) -> Effect<M>
§

Cancel

Fields

Implementations§

Source§

impl<M> Effect<M>

Source

pub fn none() -> Self

Source

pub fn task(id: EffectId, run: TaskFn<M>) -> Self

Source

pub fn from_fn<F>(run: F) -> Self
where M: Send + 'static, F: Fn() -> Pin<Box<dyn Future<Output = Result<M, EffectError>> + Send>> + Send + Sync + 'static,

Source

pub fn env_task(id: EffectId, run: EnvTaskFn<M>) -> Self

Source

pub fn from_env_fn<F>(run: F) -> Self
where M: Send + 'static, F: Fn(&Environment) -> Pin<Box<dyn Future<Output = Result<M, EffectError>> + Send>> + Send + Sync + 'static,

Source

pub fn from_run<F>(run: F) -> Self
where M: Send + 'static, F: Fn(RunSender<M>) -> Pin<Box<dyn Future<Output = Result<(), EffectError>> + Send>> + Send + Sync + 'static,

Source

pub fn task_try(id: EffectId, run: TaskFn<M>) -> Self

Single-shot async task (alias for Effect::task).

Source

pub fn result_task<T, E>( run: TaskFn<Result<T, E>>, on_ok: fn(T) -> M, on_err: fn(E) -> M, ) -> Self
where T: Send + 'static, E: Send + 'static, M: Send + 'static,

Map a Result<T, E> leaf task into M via fn pointers (UDF TaskResult).

Source

pub fn batch(effects: impl IntoIterator<Item = Effect<M>>) -> Self

Source

pub fn merge(effects: impl IntoIterator<Item = Effect<M>>) -> Self

Source

pub fn concatenate(effects: impl IntoIterator<Item = Effect<M>>) -> Self

Source

pub fn map<N>(self, f: fn(M) -> N) -> Effect<N>
where M: Send + 'static, N: Send + 'static,

Source

pub fn cancellable(id: EffectId, inner: Effect<M>) -> Self

Source

pub fn cancellable_with( id: EffectId, cancel_in_flight: bool, inner: Effect<M>, ) -> Self

Source

pub fn debounce(id: EffectId, duration: Duration, inner: Effect<M>) -> Self

Source

pub fn throttle( id: EffectId, duration: Duration, latest: bool, inner: Effect<M>, ) -> Self

Source

pub fn cancel(id: EffectId) -> Self

Source

pub fn provide(env: Environment, inner: Effect<M>) -> Self

Source

pub fn provide_dependency<D: Send + Sync + 'static>( value: D, inner: Effect<M>, ) -> Self

Scoped single-dependency override (UDF dependency override / withDependencies).

Source

pub fn retry(attempts: u32, inner: Effect<M>) -> Self

Source

pub fn timeout(duration: Duration, inner: Effect<M>) -> Self

Source

pub fn sequence(effects: impl IntoIterator<Item = Effect<M>>) -> Self

Source

pub fn race(effects: impl IntoIterator<Item = Effect<M>>) -> Self

Source

pub fn catch(inner: Effect<M>, recover: fn(EffectError) -> Effect<M>) -> Self

Trait Implementations§

Source§

impl<M> Clone for Effect<M>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M> Debug for Effect<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M> PartialEq for Effect<M>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for Effect<M>

§

impl<M> !UnwindSafe for Effect<M>

§

impl<M> Freeze for Effect<M>

§

impl<M> Send for Effect<M>

§

impl<M> Sync for Effect<M>

§

impl<M> Unpin for Effect<M>

§

impl<M> UnsafeUnpin for Effect<M>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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