pub async fn timeout<T: futures::Future>(&self, duration: Duration, future: T) -> Result<T::Output, TimedOut> {
        match &self.inner {
            #[cfg(feature = "tokio_executor")]
            TokioHandle(_) => {
                tokio::time::timeout(duration, future).await.map_err(|_| TimedOut)
            },
            #[cfg(feature = "async_std_executor")]
            AsyncStdHandle => {
                async_std::future::timeout(duration, future).await.map_err(|_| TimedOut)
            }, 
            #[cfg(feature = "smol_executor")]
            SmolHandle(_) => {
                futures_lite::future::or(async {
                    async_io::Timer::after(duration).await; Err(TimedOut)
                }, async {
                    Ok(future.await)
                }).await
            },
            #[cfg(feature = "futures_executor")]
            FuturesHandle(_) => {
                futures::pin_mut!(future);
                async_timer::timed(future, duration).await.map_err(|_| TimedOut)
            },
            #[cfg(feature = "wasm_bindgen_executor")]
            WasmBindgenHandle => {
                futures::pin_mut!(future);
                WasmTimeoutFuture::new(future, duration).await
            }
        }        
    }
/// Wraps a future in a timeout that expires after a duration if the provided future didn't finish.
Wraps a future in a timeout that expires after a duration if the provided future didn't finish.
Wraps a future in a timeout that expires after a duration if the provided future didn ' t finish .
pub async fn timeout<T: futures::Future>(&self, duration: Duration, future: T) -> Result<T::Output, TimedOut> {
        match &self.inner {
            #[cfg(feature = "tokio_executor")]
            TokioHandle(_) => {
                tokio::time::timeout(duration, future).await.map_err(|_| TimedOut)
            },
            #[cfg(feature = "async_std_executor")]
            AsyncStdHandle => {
                async_std::future::timeout(duration, future).await.map_err(|_| TimedOut)
            }, 
            #[cfg(feature = "smol_executor")]
            SmolHandle(_) => {
                futures_lite::future::or(async {
                    async_io::Timer::after(duration).await; Err(TimedOut)
                }, async {
                    Ok(future.await)
                }).await
            },
            #[cfg(feature = "futures_executor")]
            FuturesHandle(_) => {
                futures::pin_mut!(future);
                async_timer::timed(future, duration).await.map_err(|_| TimedOut)
            },
            #[cfg(feature = "wasm_bindgen_executor")]
            WasmBindgenHandle => {
                futures::pin_mut!(future);
                WasmTimeoutFuture::new(future, duration).await
            }
        }        
    }
pub async fn timeout < T : futures :: Future > ( & self , duration : Duration , future : T ) -> Result < T :: Output , TimedOut > { match & self . inner { # [ cfg ( feature " " ) ] TokioHandle ( _ ) => { tokio :: time :: timeout ( duration , future ) . await . map_err ( | _ | TimedOut ) } , # [ cfg ( feature " " ) ] AsyncStdHandle => { async_std :: future :: timeout ( duration , future ) . await . map_err ( | _ | TimedOut ) } , # [ cfg ( feature " " ) ] SmolHandle ( _ ) => { futures_lite :: future :: or ( async { async_io :: Timer :: after ( duration ) . await ; Err ( TimedOut ) } , async { Ok ( future . await ) } ) . await } , # [ cfg ( feature " " ) ] FuturesHandle ( _ ) => { futures :: pin_mut ! ( future ) ; async_timer :: timed ( future , duration ) . await . map_err ( | _ | TimedOut ) } , # [ cfg ( feature " " ) ] WasmBindgenHandle => { futures :: pin_mut ! ( future ) ; WasmTimeoutFuture :: new ( future , duration ) . await } } }
Wraps a future in a timeout that expires after a duration if the provided future didn't finish.
Wraps a future in a timeout that expires after a duration if the provided future didn ' t finish .
&self
duration
Duration
future
T