Function async_generator::generate

source ·
pub fn generate<'a, I, R, C, F>(cb: C) -> Generator<F, I, R>
where C: FnOnce(Yield<I>) -> F, F: Future<Output = R> + 'a, I: Send + 'static, R: Send + 'static,
Expand description

Produces an asynchronous Stream of GeneratorState<I, R> by invoking the given closure with a handle that can be used to yield items.

The returned Stream will produce a GeneratorState::Yielded variant for all yielded items from the asynchronous task, followed by a single GeneratorState::Complete variant, which will always be present as the final element in the stream.