futures_concurrency/future/try_join/mod.rs
1use core::future::Future;
2
3pub(crate) mod array;
4pub(crate) mod tuple;
5#[cfg(feature = "alloc")]
6pub(crate) mod vec;
7
8/// Wait for all futures to complete successfully, or abort early on error.
9///
10/// In the case a future errors, all other futures will be cancelled. If
11/// futures have been completed, their results will be discarded.
12///
13/// If you want to keep partial data in the case of failure, see the `merge`
14/// operation.
15pub trait TryJoin {
16 /// The resulting output type.
17 type Output;
18
19 /// The resulting error type.
20 type Error;
21
22 /// Which kind of future are we turning this into?
23 type Future: Future<Output = Result<Self::Output, Self::Error>>;
24
25 /// Waits for multiple futures to complete, either returning when all
26 /// futures complete successfully, or return early when any future completes
27 /// with an error.
28 fn try_join(self) -> Self::Future;
29}