Skip to main content

Yielder

Struct Yielder 

Source
pub struct Yielder<'a, Effs>
where Effs: MapResume,
{ /* private fields */ }
Expand description

Handle passed to computation closures for yielding effects.

Use yield_ to perform an effect and receive the handler’s resume value.

Implementations§

Source§

impl<'a, Effs> Yielder<'a, Effs>
where Effs: MapResume,

Source

pub async fn yield_<E, Index>(&self, effect: E) -> E::Resume<'a>
where E: Effect, Effs: CoprodInjector<E, Index>, <Effs as MapResume>::Output<'a>: CoprodUninjector<E::Resume<'a>, Index>,

Yield an effect to the handler and suspend until resumed.

Returns the resume value provided by the handler for this effect.

Source

pub async fn invoke<'b, SubEffs, R, L, Indices>( &self, program: Effectful<'b, SubEffs, R, L>, ) -> R
where SubEffs: Effects<'b> + EmbedEffect<Effs, Indices>, <Effs as MapResume>::Output<'a>: ProjectResume<'a, SubEffs, Indices>, L: Locality, 'a: 'b,

Invoke a sub-program, forwarding its effects through this yielder.

The sub-program’s effects must be a subset of this yielder’s effects. Each effect yielded by the sub-program is forwarded to the outer handler via this yielder, and the resume value is passed back to the sub-program.

Effect forwarding uses synchronous coproduct conversions ([EmbedEffect] / [ProjectResume]) combined with the raw generator yield. This works in both Send and non-Send contexts.

Returns the sub-program’s result directly. If the outer handler cancels, the entire coroutine is dropped, so invoke never returns in that case.

The sub-program may use a lifetime 'b shorter than the outer program’s 'a. This allows sequential invocations that borrow from the same mutable reference, since each invocation only borrows for its own duration rather than for the entire outer computation lifetime.

Auto Trait Implementations§

§

impl<'a, Effs> Freeze for Yielder<'a, Effs>

§

impl<'a, Effs> RefUnwindSafe for Yielder<'a, Effs>
where Effs: RefUnwindSafe, <Effs as MapResume>::Output<'a>: RefUnwindSafe,

§

impl<'a, Effs> Send for Yielder<'a, Effs>
where Effs: Send, <Effs as MapResume>::Output<'a>: Send,

§

impl<'a, Effs> Sync for Yielder<'a, Effs>
where Effs: Sync, <Effs as MapResume>::Output<'a>: Sync,

§

impl<'a, Effs> Unpin for Yielder<'a, Effs>

§

impl<'a, Effs> UnsafeUnpin for Yielder<'a, Effs>

§

impl<'a, Effs> UnwindSafe for Yielder<'a, Effs>
where Effs: UnwindSafe, <Effs as MapResume>::Output<'a>: UnwindSafe,

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<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) 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, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. 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.