pub struct Effect<R, E, A> { /* private fields */ }Implementations§
Source§impl<R, E, A> Effect<R, E, A>
impl<R, E, A> Effect<R, E, A>
Sourcepub fn async_effect<F, Fut>(f: F) -> Self
pub fn async_effect<F, Fut>(f: F) -> Self
Creates an effect from a future.
Sourcepub fn sleep(duration: Duration) -> Self
pub fn sleep(duration: Duration) -> Self
Creates an effect that sleeps for the specified duration.
Sourcepub fn with_metric_increment(self, name: &str, labels: Vec<MetricLabel>) -> Self
pub fn with_metric_increment(self, name: &str, labels: Vec<MetricLabel>) -> Self
Records a metric increment when this effect runs.
Sourcepub fn with_metric_duration(self, name: &str, labels: Vec<MetricLabel>) -> Self
pub fn with_metric_duration(self, name: &str, labels: Vec<MetricLabel>) -> Self
Records duration of this effect in a histogram.
pub fn timed(self, name: &str, labels: Vec<MetricLabel>) -> Self
Sourcepub fn access_async<F, Fut>(f: F) -> Self
pub fn access_async<F, Fut>(f: F) -> Self
Creates an effect with access to the environment.
Sourcepub fn provide(self, env: R) -> Effect<(), E, A>
pub fn provide(self, env: R) -> Effect<(), E, A>
Provides the environment to the effect, eliminating the dependency R.
pub fn map<B, F>(self, f: F) -> Effect<R, E, B>
pub fn map_error<E2, F>(self, f: F) -> Effect<R, E2, A>
pub fn flat_map<B, F>(self, f: F) -> Effect<R, E, B>
Sourcepub fn delay(self, duration: Duration) -> Effect<R, E, A>
pub fn delay(self, duration: Duration) -> Effect<R, E, A>
Delays the execution of this effect by the specified duration.
Sourcepub fn trace(self, name: &'static str) -> Effect<R, E, A>
pub fn trace(self, name: &'static str) -> Effect<R, E, A>
Wraps the effect execution in a tracing span with the given name.
Sourcepub fn on_interrupt<F, R2, E2, X>(self, cleanup: F) -> Effect<R, E, A>
pub fn on_interrupt<F, R2, E2, X>(self, cleanup: F) -> Effect<R, E, A>
Runs a cleanup effect if this effect is interrupted.
Sourcepub fn acquire_release<F, R2, E2, X>(self, release: F) -> Effect<R, E, A>
pub fn acquire_release<F, R2, E2, X>(self, release: F) -> Effect<R, E, A>
Acquires a resource, then registers a finalizer to release it. The release effect is guaranteed to run when the scope closes.
Sourcepub fn zip_par<B>(self, other: Effect<R, E, B>) -> Effect<R, E, (A, B)>
pub fn zip_par<B>(self, other: Effect<R, E, B>) -> Effect<R, E, (A, B)>
Runs this effect and another effect in parallel, returning both results. If either effect fails, the other is interrupted.
pub fn race(self, other: Effect<R, E, A>) -> Effect<R, E, A>
pub fn collect_all_par<I>(effects: I) -> Effect<R, E, Vec<A>>
Trait Implementations§
Auto Trait Implementations§
impl<R, E, A> Freeze for Effect<R, E, A>
impl<R, E, A> !RefUnwindSafe for Effect<R, E, A>
impl<R, E, A> Send for Effect<R, E, A>
impl<R, E, A> Sync for Effect<R, E, A>
impl<R, E, A> Unpin for Effect<R, E, A>
impl<R, E, A> !UnwindSafe for Effect<R, E, A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more