pub enum Poll {
Ready(T),
Pending,
}
Expand description
Indicates whether a value is available or if the current task has been scheduled to receive a wakeup instead.
This is returned by Future::poll
.
Variants§
Ready(T)
Represents that a value is immediately ready.
Pending
Represents that a value is not ready yet.
When a function returns Pending
, the function must also
ensure that the current task is scheduled to be awoken when
progress can be made.
Implementations§
Source§impl Poll
impl Poll
1.36.0 · Sourcepub fn map(self, f: F) -> Pollwhere
F: FnOnce(T) -> U,
pub fn map(self, f: F) -> Pollwhere
F: FnOnce(T) -> U,
1.36.0 (const: 1.49.0) · Sourcepub const fn is_ready(&self) -> bool
pub const fn is_ready(&self) -> bool
Returns true
if the poll is a Poll::Ready
value.
§Examples
1.36.0 (const: 1.49.0) · Sourcepub const fn is_pending(&self) -> bool
pub const fn is_pending(&self) -> bool
Source§impl Poll<Result>
impl Poll<Result>
1.36.0 · Sourcepub fn map_ok(self, f: F) -> Poll<Result>where
F: FnOnce(T) -> U,
pub fn map_ok(self, f: F) -> Poll<Result>where
F: FnOnce(T) -> U,
Maps a Poll
to Poll
by applying a
function to a contained Poll::Ready(Ok)
value, leaving all other
variants untouched.
This function can be used to compose the results of two functions.
§Examples
1.36.0 · Sourcepub fn map_err(self, f: F) -> Poll<Result>where
F: FnOnce(E) -> U,
pub fn map_err(self, f: F) -> Poll<Result>where
F: FnOnce(E) -> U,
Maps a Poll::Ready
to Poll::Ready
by
applying a function to a contained Poll::Ready(Err)
value, leaving all other
variants untouched.
This function can be used to pass through a successful result while handling an error.
§Examples
Source§impl Poll<Option<Result>>
impl Poll<Option<Result>>
1.51.0 · Sourcepub fn map_ok(self, f: F) -> Poll<Option<Result>>where
F: FnOnce(T) -> U,
pub fn map_ok(self, f: F) -> Poll<Option<Result>>where
F: FnOnce(T) -> U,
Maps a Poll
to Poll
by
applying a function to a contained Poll::Ready(Some(Ok))
value,
leaving all other variants untouched.
This function can be used to compose the results of two functions.
§Examples
1.51.0 · Sourcepub fn map_err(self, f: F) -> Poll<Option<Result>>where
F: FnOnce(E) -> U,
pub fn map_err(self, f: F) -> Poll<Option<Result>>where
F: FnOnce(E) -> U,
Maps a Poll::Ready
to
Poll::Ready
by applying a function to a
contained Poll::Ready(Some(Err))
value, leaving all other variants
untouched.
This function can be used to pass through a successful result while handling an error.
§Examples
Trait Implementations§
Source§impl FromResidual<Result<Infallible, E>> for Poll<Option<Result>>where
F: From,
impl FromResidual<Result<Infallible, E>> for Poll<Option<Result>>where
F: From,
Source§fn from_residual(x: Result<Infallible, E>) -> Poll<Option<Result>>
fn from_residual(x: Result<Infallible, E>) -> Poll<Option<Result>>
try_trait_v2
#84277)Residual
type. Read moreSource§impl FromResidual<Result<Infallible, E>> for Poll<Result>where
F: From,
impl FromResidual<Result<Infallible, E>> for Poll<Result>where
F: From,
Source§fn from_residual(x: Result<Infallible, E>) -> Poll<Result>
fn from_residual(x: Result<Infallible, E>) -> Poll<Result>
try_trait_v2
#84277)Residual
type. Read more1.36.0 · Source§impl Ord for Pollwhere
T: Ord,
impl Ord for Pollwhere
T: Ord,
1.36.0 · Source§impl PartialOrd for Pollwhere
T: PartialOrd,
impl PartialOrd for Pollwhere
T: PartialOrd,
Source§impl Try for Poll<Option<Result>>
impl Try for Poll<Option<Result>>
Source§type Output = Poll<Option>
type Output = Poll<Option>
try_trait_v2
#84277)?
when not short-circuiting.Source§type Residual = Result<Infallible, E>
type Residual = Result<Infallible, E>
try_trait_v2
#84277)FromResidual::from_residual
as part of ?
when short-circuiting. Read moreSource§fn from_output(
c: <Poll<Option<Result>> as Try>::Output,
) -> Poll<Option<Result>>
fn from_output(
c: <Poll<Option<Result>> as Try>::Output,
) -> Poll<Option<Result>>
try_trait_v2
#84277)Output
type. Read moreSource§fn branch(
self,
) -> ControlFlow<<Poll<Option<Result>> as Try>::Residual, <Poll<Option<Result>> as Try>::Output>
fn branch(
self,
) -> ControlFlow<<Poll<Option<Result>> as Try>::Residual, <Poll<Option<Result>> as Try>::Output>
try_trait_v2
#84277)?
to decide whether the operator should produce a value
(because this returned ControlFlow::Continue
)
or propagate a value back to the caller
(because this returned ControlFlow::Break
). Read moreSource§impl Try for Poll<Result>
impl Try for Poll<Result>
Source§type Output = Poll
type Output = Poll
try_trait_v2
#84277)?
when not short-circuiting.Source§type Residual = Result<Infallible, E>
type Residual = Result<Infallible, E>
try_trait_v2
#84277)FromResidual::from_residual
as part of ?
when short-circuiting. Read moreSource§fn from_output(c: <Poll<Result> as Try>::Output) -> Poll<Result>
fn from_output(c: <Poll<Result> as Try>::Output) -> Poll<Result>
try_trait_v2
#84277)Output
type. Read moreSource§fn branch(
self,
) -> ControlFlow<<Poll<Result> as Try>::Residual, <Poll<Result> as Try>::Output>
fn branch(
self,
) -> ControlFlow<<Poll<Result> as Try>::Residual, <Poll<Result> as Try>::Output>
try_trait_v2
#84277)?
to decide whether the operator should produce a value
(because this returned ControlFlow::Continue
)
or propagate a value back to the caller
(because this returned ControlFlow::Break
). Read more