Mirror of https://github.com/roostorg/osprey github.com/roostorg/osprey
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 15 lines 539 B view raw
1use std::future::Future; 2use std::io::{Error as IoError, ErrorKind}; 3use std::time::Instant; 4 5/// Utility function for timing out a future without having to double unwrap the result. 6/// It collapses the two results into a single result. 7pub async fn timeout_at<F, O, E>(deadline: Instant, future: F) -> F::Output 8where 9 F: Future<Output = Result<O, E>>, 10 E: From<IoError>, 11{ 12 tokio::time::timeout_at(deadline.into(), future) 13 .await 14 .unwrap_or_else(|_e| Err(IoError::new(ErrorKind::TimedOut, "timeout").into())) 15}