pub enum Poll<T> {
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<T> Poll<T>
impl<T> Poll<T>
1.36.0 · Sourcepub fn map<U, F>(self, f: F) -> Poll<U>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> Poll<U>where
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<T, E> Poll<Result<T, E>>
impl<T, E> Poll<Result<T, E>>
1.36.0 · Sourcepub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>>where
F: FnOnce(T) -> U,
pub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>>where
F: FnOnce(T) -> U,
Maps a Poll<Result<T, E>>
to Poll<Result<U, E>>
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<U, F>(self, f: F) -> Poll<Result<T, U>>where
F: FnOnce(E) -> U,
pub fn map_err<U, F>(self, f: F) -> Poll<Result<T, U>>where
F: FnOnce(E) -> U,
Maps a Poll::Ready<Result<T, E>>
to Poll::Ready<Result<T, F>>
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<T, E> Poll<Option<Result<T, E>>>
impl<T, E> Poll<Option<Result<T, E>>>
1.51.0 · Sourcepub fn map_ok<U, F>(self, f: F) -> Poll<Option<Result<U, E>>>where
F: FnOnce(T) -> U,
pub fn map_ok<U, F>(self, f: F) -> Poll<Option<Result<U, E>>>where
F: FnOnce(T) -> U,
Maps a Poll<Option<Result<T, E>>>
to Poll<Option<Result<U, E>>>
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<U, F>(self, f: F) -> Poll<Option<Result<T, U>>>where
F: FnOnce(E) -> U,
pub fn map_err<U, F>(self, f: F) -> Poll<Option<Result<T, U>>>where
F: FnOnce(E) -> U,
Maps a Poll::Ready<Option<Result<T, E>>>
to
Poll::Ready<Option<Result<T, F>>>
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<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Poll<Option<Result<T, F>>>
impl<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Poll<Option<Result<T, F>>>
Source§fn from_residual(x: Result<Infallible, E>) -> Self
fn from_residual(x: Result<Infallible, E>) -> Self
try_trait_v2
#84277)Residual
type. Read moreSource§impl<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Poll<Result<T, F>>
impl<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Poll<Result<T, F>>
Source§fn from_residual(x: Result<Infallible, E>) -> Self
fn from_residual(x: Result<Infallible, E>) -> Self
try_trait_v2
#84277)Residual
type. Read more1.36.0 · Source§impl<T: Ord> Ord for Poll<T>
impl<T: Ord> Ord for Poll<T>
1.36.0 · Source§impl<T: PartialOrd> PartialOrd for Poll<T>
impl<T: PartialOrd> PartialOrd for Poll<T>
Source§impl<T, E> Try for Poll<Option<Result<T, E>>>
impl<T, E> Try for Poll<Option<Result<T, E>>>
Source§type Output = Poll<Option<T>>
type Output = Poll<Option<T>>
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: Self::Output) -> Self
fn from_output(c: Self::Output) -> Self
try_trait_v2
#84277)Output
type. Read moreSource§fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
fn branch(self) -> ControlFlow<Self::Residual, Self::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<T, E> Try for Poll<Result<T, E>>
impl<T, E> Try for Poll<Result<T, E>>
Source§type Output = Poll<T>
type Output = Poll<T>
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: Self::Output) -> Self
fn from_output(c: Self::Output) -> Self
try_trait_v2
#84277)Output
type. Read moreSource§fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
fn branch(self) -> ControlFlow<Self::Residual, Self::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