Skip to main content

with_network_timeout

Function with_network_timeout 

Source
pub async fn with_network_timeout<F, T>(fut: F, timeout: Duration) -> Option<T>
where F: Future<Output = T>,
Expand description

Wrap a future with a wall-clock timeout.

Returns Some(value) if the future completes before timeout elapses, or None if it times out.

ยงExamples

use ipfrs_cli::connectivity::{with_network_timeout, DAEMON_CHECK_TIMEOUT};

async fn example() {
    let result = with_network_timeout(
        async { 42_u32 },
        DAEMON_CHECK_TIMEOUT,
    ).await;
    assert_eq!(result, Some(42));
}