maitake::time

Struct Timeout

Source
pub struct Timeout<'timer, F> { /* private fields */ }
Expand description

A Future that requires an inner Future to complete within a specified Duration.

This Future is returned by the timeout and try_timeout functions, and by the Timer::timeout and Timer::try_timeout methods.

§Output

  • Ok(F::Output) if the inner future completed before the specified timeout.
  • Err(Elapsed) if the timeout elapsed before the inner Future completed.

§Cancellation

Dropping a Timeout future cancels the timeout. The wrapped Future can be extracted from the Timeout future by calling Timeout::into_inner, allowing the future to be polled without failing if the timeout elapses.

Implementations§

Source§

impl<'timer, F: Future> Timeout<'timer, F>

Source

pub fn into_inner(self) -> F

Consumes this Timeout, returning the inner Future.

This can be used to continue polling the inner Future without requiring it to complete prior to the specified timeout.

Source

pub fn get_ref(&self) -> &F

Borrows the inner Future immutably.

Source

pub fn get_mut(&mut self) -> &mut F

Mutably the inner Future.

Source

pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut F>

Borrows the inner Future as a Pinned reference, if this Timeout is pinned.

Source

pub fn duration(&self) -> Duration

Returns the Duration the inner Future is allowed to run for.

Trait Implementations§

Source§

impl<'timer, F: Debug> Debug for Timeout<'timer, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: Future> Future for Timeout<'_, F>

Source§

type Output = Result<<F as Future>::Output, Elapsed>

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Source§

impl<'pin, 'timer, F> Unpin for Timeout<'timer, F>
where __Timeout<'pin, 'timer, F>: Unpin,

Auto Trait Implementations§

§

impl<'timer, F> !Freeze for Timeout<'timer, F>

§

impl<'timer, F> !RefUnwindSafe for Timeout<'timer, F>

§

impl<'timer, F> Send for Timeout<'timer, F>
where F: Send,

§

impl<'timer, F> !Sync for Timeout<'timer, F>

§

impl<'timer, F> !UnwindSafe for Timeout<'timer, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.