[−][src]Trait eff::Effectful
An effectful computation
Associated Types
type Output
The type of the final result
type Effect
The type of the effects this computation will produce
Required methods
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
Resume the computation to a final value, registering the current task for wakeup if a handler starts handling an effect performed by the task
Return value
This function returns:
Poll::Done(v)
with a resultv
if the computation completed successfullyPoll::Effect(e)
with an effecte
if the computation performed a computational effectPoll::Pending
if the computation is not ready to continue because a handler is handling an effect
Once a computation has completed, clients should not poll
it again
When a computation performs an effect, poll
returns Poll::Effect(e)
with the effect e
When a handler decides to handle an effect, it will register interest in the result for the
current task. In this case, poll
returns Poll::NotReady
until the task gets woken up
with the outcome of the effect.
Panics
After the completion of the computation (poll
returned Poll::Done
), future calls to poll
may panic or cause bad behavior. The Effectful
trait does not provide any guarantees
about the safety of calling poll
after the task has finished.
Provided methods
fn handle<H, HC, Effect, I>(self, handler: H) -> Handled<Self, H, HC, Effect, I> where
Self: Sized,
HC: Effectful,
H: FnMut(Event<Self::Output, Effect>) -> HC,
Self::Effect: Subset<Effect, I>,
Self: Sized,
HC: Effectful,
H: FnMut(Event<Self::Output, Effect>) -> HC,
Self::Effect: Subset<Effect, I>,
Takes a value handler and an effect handler and creates an effectful computation with the effects handled
fn embed<Target, Indices>(self) -> EmbedEffect<Self, Target, Indices> where
Self: Sized,
Self: Sized,
Creates an effectful computation whose effect is a superset of that of this one
fn left<R>(self) -> Either<Self, R> where
Self: Sized,
Self: Sized,
Combine this and the other computation with the same signature
fn right<L>(self) -> Either<L, Self> where
Self: Sized,
Self: Sized,
Combine this and the other computation with the same signature
fn boxed<'a>(
self
) -> Pin<Box<dyn Effectful<Output = Self::Output, Effect = Self::Effect> + 'a>> where
Self: Sized + 'a,
self
) -> Pin<Box<dyn Effectful<Output = Self::Output, Effect = Self::Effect> + 'a>> where
Self: Sized + 'a,
Create a boxed computation
This function can be used to erase Self
type
fn output<T>(self) -> Self where
Self: Effectful<Output = T> + Sized,
Self: Effectful<Output = T> + Sized,
fn effect<E>(self) -> Self where
Self: Effectful<Effect = E> + Sized,
Self: Effectful<Effect = E> + Sized,
ⓘImportant traits for IntoFuture<C>fn into_future(self) -> IntoFuture<Self> where
Self: Effectful<Effect = !> + Sized,
Self: Effectful<Effect = !> + Sized,
fn block_on(self) -> Self::Output where
Self: Sized + Effectful<Effect = !>,
Self: Sized + Effectful<Effect = !>,
Run the computation to completion on the current thread
This method blocks the current thread while waiting on the progress of the computation
The effect type of this computation must be an empty set (never type) since there is no handler
fn next_event(self) -> NextEvent<Self> where
Self: Sized,
Self: Sized,
Create a computation which polls this until the first event occures.
Implementations on Foreign Types
impl<'_, C: ?Sized> Effectful for &'_ mut C where
C: Effectful + Unpin,
[src]
C: Effectful + Unpin,
type Output = C::Output
type Effect = C::Effect
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<'_, C: ?Sized> Effectful for Pin<&'_ mut C> where
C: Effectful,
[src]
C: Effectful,
type Output = C::Output
type Effect = C::Effect
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<C: ?Sized> Effectful for Box<C> where
C: Effectful + Unpin,
[src]
C: Effectful + Unpin,
type Output = C::Output
type Effect = C::Effect
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<C: ?Sized> Effectful for Pin<Box<C>> where
C: Effectful,
[src]
C: Effectful,
type Output = C::Output
type Effect = C::Effect
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
Implementors
impl<C, Output, Effect, H, HC, HandledEffect, NewOutput, NewEffect, I> Effectful for Handled<C, H, HC, HandledEffect, I> where
C: Effectful<Output = Output, Effect = Effect>,
H: FnMut(Event<Output, HandledEffect>) -> HC,
HC: Effectful<Output = NewOutput, Effect = Either<Continue<NewOutput>, NewEffect>>,
Effect: Subset<HandledEffect, I, Remainder = NewEffect>,
[src]
C: Effectful<Output = Output, Effect = Effect>,
H: FnMut(Event<Output, HandledEffect>) -> HC,
HC: Effectful<Output = NewOutput, Effect = Either<Continue<NewOutput>, NewEffect>>,
Effect: Subset<HandledEffect, I, Remainder = NewEffect>,
type Output = NewOutput
type Effect = NewEffect
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<C, Target, Indices> Effectful for EmbedEffect<C, Target, Indices> where
C: Effectful,
C::Effect: Embed<Target, Indices>,
[src]
C: Effectful,
C::Effect: Embed<Target, Indices>,
type Output = C::Output
type Effect = Target
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<C: Effectful> Effectful for NextEvent<C>
[src]
type Output = ()
type Effect = !
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<F> Effectful for FromFuture<F> where
F: Future,
[src]
F: Future,
type Output = F::Output
type Effect = !
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<Output, Effect, L, R> Effectful for Either<L, R> where
L: Effectful<Output = Output, Effect = Effect>,
R: Effectful<Output = Output, Effect = Effect>,
[src]
L: Effectful<Output = Output, Effect = Effect>,
R: Effectful<Output = Output, Effect = Effect>,
type Output = Output
type Effect = Effect
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<S> Effectful for FromStream<S> where
S: Stream,
[src]
S: Stream,
type Output = ()
type Effect = Item<S::Item>
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<T, Effect, F> Effectful for PollFn<F> where
F: FnMut(&Context) -> Poll<T, Effect>,
[src]
F: FnMut(&Context) -> Poll<T, Effect>,
type Output = T
type Effect = Effect
fn poll(self: Pin<&mut Self>, cx: &Context) -> Poll<Self::Output, Self::Effect>
[src]
impl<T, F> Effectful for Lazy<F> where
F: FnOnce() -> T,
[src]
F: FnOnce() -> T,