跳到主要内容
本页尚未翻译

下面显示的是英文原文。

Until

run_until serves until a future of yours resolves, then shuts the service down gracefully.

It starts the service the way run does, and installs no signal handlers. The future starts once the service has started, so it may publish to the service and wait for the answer. A subscriber that fails fast ends the run before the future resolves, and run_until returns that failure as its error.

Example​

/// Runs the service until `work` resolves; `work` starts once the service has started.
async fn serve_until(
broker: MemoryBroker,
work: impl Future<Output = ()> + Send,
) -> Result<(), Box<dyn Error>> {
app(broker).run_until(work).await?;
Ok(())
}