Skip to main content

timeout

Function timeout 

Source
pub fn timeout<F>(now: Time, duration: Duration, future: F) -> TimeoutFuture<F> 
Expand description

Creates a TimeoutFuture that wraps the given future with a timeout.

§Arguments

  • now - The current time
  • duration - How long until the timeout expires
  • future - The future to wrap

§Example

use asupersync::time::timeout;
use asupersync::types::Time;
use std::time::Duration;
use std::future::ready;

let future = timeout(Time::ZERO, Duration::from_secs(5), ready(42));
assert_eq!(future.deadline(), Time::from_secs(5));