clementine_core::utils

Function timed_try_join_all

Source
pub async fn timed_try_join_all<I, T, D>(
    duration: Duration,
    description: &str,
    ids: Option<Vec<D>>,
    iter: I,
) -> Result<Vec<T>, BridgeError>
where D: Display, I: IntoIterator, I::Item: Future<Output = Result<T, BridgeError>>,
Expand description

Concurrently executes a collection of futures, applying a timeout to each one individually. If any future fails or times out, the entire operation is aborted and an error is returned.

This utility is an extension of futures::future::try_join_all with added per-future timeout logic and improved error reporting using optional IDs.

§Type Parameters

  • I: An iterator that yields futures.
  • T: The success type of the futures.
  • D: A type that can be displayed, used for identifying futures in error messages.

§Arguments

  • duration: The timeout Duration applied to each individual future in the iterator.
  • description: A string slice describing the collective operation, used in timeout error messages.
  • ids: An optional Vec<D> of identifiers corresponding to each future. If provided, these IDs are used in error messages to specify which future failed or timed out.
  • iter: An iterator producing the futures to be executed.

§Returns

Returns Ok(Vec<T>) containing the results of all futures if they all complete successfully. Returns Err(BridgeError) if any future returns an error or times out. The error will be contextualized with the operation description and the specific future’s ID if available.