Skip to main content

drive

Function drive 

Source
pub async fn drive<F, Fut>(
    algorithm: Arc<dyn Algorithm>,
    request: Request,
    models: Arc<RuntimeModels>,
    serve: F,
) -> Result<RoutingOutcome>
where F: Fn(Call) -> Fut, Fut: Future<Output = Result<()>>,
Expand description

Drive Algorithm::run_stream to its routing outcome, serving calls concurrently.

The shared execution loop lets hosts supply clients or test doubles through serve without reimplementing stream handling and cancellation.

serve owns each Call and performs its I/O. Passing an error to respond lets the algorithm fall back; returning an error from serve aborts the run.

Dropping this future cancels the algorithm and pending handler futures.