[][src]Trait context_coroutine::Coroutine

pub trait Coroutine: Sized {
    type StartArguments: Sized;
    type ResumeArguments: Sized;
    type Yields: Sized;
    type Complete: Sized;
    fn coroutine<'yielder>(
        start_arguments: Self::StartArguments,
        yielder: Yielder<'yielder, Self::ResumeArguments, Self::Yields, Self::Complete>
    ) -> Self::Complete; fn start_coroutine<S: Stack>(
        stack: S,
        start_arguments: Self::StartArguments
    ) -> StartOutcome<S, Self> { ... } }

A trait that stackful coroutines should implement.

Start a new instance of this coroutine by using Self::start_coroutine().

Associated Types

type StartArguments: Sized

Type of the arguments the coroutine is initially called with, eg (usize, String).

type ResumeArguments: Sized

Type of the arguments the coroutine is resumed with, eg (u8, Vec<f64>).

type Yields: Sized

Type of the result from a yield of the coroutine.

type Complete: Sized

Type of the final result from the coroutine.

Loading content...

Required methods

fn coroutine<'yielder>(
    start_arguments: Self::StartArguments,
    yielder: Yielder<'yielder, Self::ResumeArguments, Self::Yields, Self::Complete>
) -> Self::Complete

Implement this for the coroutine's behaviour.

Panics inside the coroutine are transferred to the calling thread and raised.

Loading content...

Provided methods

fn start_coroutine<S: Stack>(
    stack: S,
    start_arguments: Self::StartArguments
) -> StartOutcome<S, Self>

Starts the coroutine; execution will transfer to the coroutine.

Ownership of start_arguments will also transfer.

Returns the data transferred to us after the start and a guard object to resume the coroutine again or the final result.

If the coroutine panicked, this panics.

Loading content...

Implementors

Loading content...