Skip to main content

try_join_with_drain

Function try_join_with_drain 

pub async fn try_join_with_drain<A, B, E>(
    left: impl Future<Output = Result<A, E>>,
    right: impl Future<Output = Result<B, E>>,
    timeout: Option<Duration>,
    on_timeout: impl FnOnce() -> E,
) -> Result<(A, B), E>
Expand description

Drive two fallible directions, bounding the remaining work after either succeeds.

An error cancels the sibling immediately. Callers translate their protocol’s normal directional ends (including a closed destination) into success before joining. timeout starts only after the first success; None permits an unbounded drain. No task is spawned and dropping this future drops both directions.