pipeline-toolkit 0.2.0

A small toolkit for building linear, async processing pipelines out of independently testable steps that communicate through a shared, type-keyed Context.
Documentation
use std::future::Future;
use std::task::{Context as TaskContext, Poll, Waker};

/// Drives a future to completion by busy-polling with a no-op waker. Only
/// suitable for futures that are always immediately ready (as `Step::run`
/// implementations in these tests are); a future that relies on being
/// woken rather than on polling-visible state would spin here forever,
/// since a no-op waker never schedules a re-poll. Bound the spin count so
/// such a future panics quickly instead of hanging the test suite.
pub(crate) fn block_on<F: Future>(fut: F) -> F::Output {
    let mut fut = std::pin::pin!(fut);
    let mut cx = TaskContext::from_waker(Waker::noop());
    for _ in 0..1_000_000 {
        if let Poll::Ready(val) = fut.as_mut().poll(&mut cx) {
            return val;
        }
    }
    panic!("block_on: future did not resolve after 1,000,000 polls");
}