[][src]Struct smol_timeout::Timeout

pub struct Timeout<Fut: Future> { /* fields omitted */ }

A future polling both another future and a [Timer] that will complete after a specified timeout, and returning the future's output or None if the timer completes first.

Example

use smol_timeout::TimeoutExt;
use std::time::Duration;

let foo = async {
    Timer::after(Duration::from_millis(250)).await;
    24
};

let foo = foo.timeout(Duration::from_millis(100));
assert_eq!(foo.await, None);

let bar = async {
    Timer::after(Duration::from_millis(100)).await;
    42
};

let bar = bar.timeout(Duration::from_millis(250));
assert_eq!(bar.await, Some(42));

Trait Implementations

impl<Fut: Debug + Future> Debug for Timeout<Fut>[src]

impl<Fut: Future> Future for Timeout<Fut>[src]

type Output = Option<Fut::Output>

The type of value produced on completion.

impl<'__pin, Fut: Future> Unpin for Timeout<Fut> where
    __Origin<'__pin, Fut>: Unpin
[src]

Auto Trait Implementations

impl<Fut> RefUnwindSafe for Timeout<Fut> where
    Fut: RefUnwindSafe

impl<Fut> Send for Timeout<Fut> where
    Fut: Send

impl<Fut> Sync for Timeout<Fut> where
    Fut: Sync

impl<Fut> UnwindSafe for Timeout<Fut> where
    Fut: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<F> FutureExt for F where
    F: Future + ?Sized

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<Fut> TimeoutExt for Fut where
    Fut: Future
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.