[−][src]Trait context_coroutine::Coroutine
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.
Required methods
fn coroutine<'yielder>(
start_arguments: Self::StartArguments,
yielder: Yielder<'yielder, Self::ResumeArguments, Self::Yields, Self::Complete>
) -> Self::Complete
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.
Provided methods
fn start_coroutine<S: Stack>(
stack: S,
start_arguments: Self::StartArguments
) -> StartOutcome<S, Self>
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.