clementine_core::utils

Function timed_request_base

Source
pub async fn timed_request_base<F, T>(
    duration: Duration,
    description: &str,
    future: F,
) -> Result<Result<T, BridgeError>, Elapsed>
where F: Future<Output = Result<T, BridgeError>>,
Expand description

Wraps a future with a timeout and adds a debug span with the description.

§Arguments

  • duration: The maximum Duration to wait for the future to complete.
  • description: A string slice describing the operation, used in the timeout error message.
  • future: The Future to execute. The future should return a Result<T, BridgeError>.

§Returns

Returns Ok(Ok(T)) if the future completes successfully within the time limit, returns Ok(Err(e)) if the future returns an error, returns Err(Elapsed) if the request times out.