pub trait AsyncGenerator {
type Yield;
type Return;
// Required method
fn poll_resume(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<GeneratorState<Self::Yield, Self::Return>>;
}
Expand description
Generators, also commonly referred to as coroutines.
Required Associated Types§
Required Methods§
Sourcefn poll_resume(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<GeneratorState<Self::Yield, Self::Return>>
fn poll_resume( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<GeneratorState<Self::Yield, Self::Return>>
Resumes the execution of this generator.
This function will resume execution of the generator or start execution
if it hasn’t already. This call will return back into the generator’s
last suspension point, resuming execution from the latest yield
. The
generator will continue executing until it either yields or returns, at
which point this function will return.
§Return value
The GeneratorState
enum returned from this function indicates what
state the generator is in upon returning. If the Yielded
variant is
returned then the generator has reached a suspension point and a value
has been yielded out. Generators in this state are available for
resumption at a later point.
If Complete
is returned then the generator has completely finished
with the value provided. It is invalid for the generator to be resumed
again.
§Panics
This function may panic if it is called after the Complete
variant has
been returned previously. While generator literals in the language are
guaranteed to panic on resuming after Complete
, this is not guaranteed
for all implementations of the Generator
trait.