pub struct Timeout { /* private fields */ }
Expand description
A future representing the notification that a timeout has occurred.
Timeouts are created through the Timeout::new
or
Timeout::new_at
methods indicating when a timeout should fire at.
Note that timeouts are not intended for high resolution timers, but rather
they will likely fire some granularity after the exact instant that they’re
otherwise indicated to fire at.
Implementations§
Source§impl Timeout
impl Timeout
Sourcepub fn new(dur: Duration, handle: &Handle) -> Result<Timeout>
pub fn new(dur: Duration, handle: &Handle) -> Result<Timeout>
Creates a new timeout which will fire at dur
time into the future.
This function will return a Result with the actual timeout object or an error. The timeout object itself is then a future which will be set to fire at the specified point in the future.
Sourcepub fn new_at(at: Instant, handle: &Handle) -> Result<Timeout>
pub fn new_at(at: Instant, handle: &Handle) -> Result<Timeout>
Creates a new timeout which will fire at the time specified by at
.
This function will return a Result with the actual timeout object or an error. The timeout object itself is then a future which will be set to fire at the specified point in the future.
Sourcepub fn reset(&mut self, at: Instant)
pub fn reset(&mut self, at: Instant)
Resets this timeout to an new timeout which will fire at the time
specified by at
.
This method is usable even of this instance of Timeout
has “already
fired”. That is, if this future has resolved, calling this method means
that the future will still re-resolve at the specified instant.
If at
is in the past then this future will immediately be resolved
(when poll
is called).
Note that if any task is currently blocked on this future then that task
will be dropped. It is required to call poll
again after this method
has been called to ensure that a task is blocked on this future.
Trait Implementations§
Source§impl Future for Timeout
impl Future for Timeout
Source§type Error = Error
type Error = Error
Source§fn poll(&mut self) -> Poll<(), Error>
fn poll(&mut self) -> Poll<(), Error>
Source§fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
Source§fn map<F, U>(self, f: F) -> Map<Self, F>
fn map<F, U>(self, f: F) -> Map<Self, F>
Source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
Source§fn from_err<E>(self) -> FromErr<Self, E>
fn from_err<E>(self) -> FromErr<Self, E>
From
for
this future’s Error
, returning a new future. Read moreSource§fn then<F, B>(self, f: F) -> Then<Self, B, F>
fn then<F, B>(self, f: F) -> Then<Self, B, F>
f
. Read moreSource§fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
Source§fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>
Source§fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>
fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>
Source§fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
Source§fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>
fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>
Source§fn join3<B, C>(
self,
b: B,
c: C,
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>
fn join3<B, C>( self, b: B, c: C, ) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>
join
, but with more futures.Source§fn join4<B, C, D>(
self,
b: B,
c: C,
d: D,
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join4<B, C, D>(
self,
b: B,
c: C,
d: D,
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.Source§fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E,
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E,
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. Read more