[−][src]Struct smol_timeout::Timeout
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.
fn poll(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Self::Output>
[src]
impl<'__pin, Fut: Future> Unpin for Timeout<Fut> where
__Origin<'__pin, Fut>: Unpin,
[src]
__Origin<'__pin, Fut>: Unpin,
Auto Trait Implementations
impl<Fut> RefUnwindSafe for Timeout<Fut> where
Fut: RefUnwindSafe,
Fut: RefUnwindSafe,
impl<Fut> Send for Timeout<Fut> where
Fut: Send,
Fut: Send,
impl<Fut> Sync for Timeout<Fut> where
Fut: Sync,
Fut: Sync,
impl<Fut> UnwindSafe for Timeout<Fut> where
Fut: UnwindSafe,
Fut: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<F> FutureExt for F where
F: Future + ?Sized,
F: Future + ?Sized,
fn or<F>(self, other: F) -> Or<Self, F> where
F: Future<Output = Self::Output>,
F: Future<Output = Self::Output>,
fn boxed(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'static + Send>> where
Self: Send + 'static,
Self: Send + 'static,
fn boxed_local(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'static>> where
Self: 'static,
Self: 'static,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Fut> TimeoutExt for Fut where
Fut: Future,
[src]
Fut: Future,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,