Skip to main content

with_timeout

Function with_timeout 

Source
pub async fn with_timeout<F, T>(
    duration: Duration,
    op_name: &str,
    future: F,
) -> FetchiumResult<T>
where F: Future<Output = FetchiumResult<T>>,
Expand description

Wrap any async operation with a timeout (PRD SS44: “Never hang”).

§Example

use fetchium_core::error::with_timeout;
use tokio::time::Duration;
let result = with_timeout(Duration::from_secs(10), "fetch", async {
    Ok(())
}).await;