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<Option<T>>
impl<T> Poll<Option<T>>
Source#[doc(hidden)] pub const PENDING: Poll<Option<T>> = Poll::Pending
🔬This is a nightly-only experimental API. (async_gen_internals
)
#[doc(hidden)] pub const PENDING: Poll<Option<T>> = Poll::Pending
async_gen_internals
)A helper constant for internal desugaring – produces Pending
,
which corresponds to the async iterator pending on an .await
.
Source#[doc(hidden)] pub const FINISHED: Poll<Option<T>>
🔬This is a nightly-only experimental API. (async_gen_internals
)
#[doc(hidden)] pub const FINISHED: Poll<Option<T>>
async_gen_internals
)A helper constant for internal desugaring – produces Ready(None)
,
which corresponds to the async iterator finishing its iteration.
Source#[doc(hidden)] pub fn async_gen_ready(t: T) -> Poll<Option<T>>
🔬This is a nightly-only experimental API. (async_gen_internals
)
#[doc(hidden)] pub fn async_gen_ready(t: T) -> Poll<Option<T>>
async_gen_internals
)A helper function for internal desugaring – produces Ready(Some(t))
,
which corresponds to the async iterator yielding a value.
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§
1.36.0 · Source§impl<T> Eq for Poll<T>where
T: Eq,
impl<T> Eq for Poll<T>where
T: Eq,
#[doc(hidden)] fn assert_receiver_is_total_eq(&self)
Source§impl<T, E, F> FromResidual<Result<Infallible, E>> for Poll<Option<Result<T, F>>>where
F: From<E>,
impl<T, E, F> FromResidual<Result<Infallible, E>> for Poll<Option<Result<T, F>>>where
F: From<E>,
Source§fn from_residual(x: Result<Infallible, E>) -> Poll<Option<Result<T, F>>>
fn from_residual(x: Result<Infallible, E>) -> Poll<Option<Result<T, F>>>
try_trait_v2
#84277)Residual
type. Read moreSource§impl<T, E, F> FromResidual<Result<Infallible, E>> for Poll<Result<T, F>>where
F: From<E>,
impl<T, E, F> FromResidual<Result<Infallible, E>> for Poll<Result<T, F>>where
F: From<E>,
Source§fn from_residual(x: Result<Infallible, E>) -> Poll<Result<T, F>>
fn from_residual(x: Result<Infallible, E>) -> Poll<Result<T, F>>
try_trait_v2
#84277)Residual
type. Read more1.36.0 · Source§impl<T> Ord for Poll<T>where
T: Ord,
impl<T> Ord for Poll<T>where
T: Ord,
1.36.0 · Source§impl<T> PartialOrd for Poll<T>where
T: PartialOrd,
impl<T> PartialOrd for Poll<T>where
T: PartialOrd,
Source§#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)self == other
, returns ControlFlow::Continue(())
.
Otherwise, returns ControlFlow::Break(self < other)
. Read moreSource§#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for <=
instead of <
.Source§#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for >
instead of <
.Source§#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for >=
instead of <
.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: <Poll<Option<Result<T, E>>> as Try>::Output,
) -> Poll<Option<Result<T, E>>>
fn from_output( c: <Poll<Option<Result<T, E>>> as Try>::Output, ) -> Poll<Option<Result<T, E>>>
try_trait_v2
#84277)Output
type. Read moreSource§fn branch(
self,
) -> ControlFlow<<Poll<Option<Result<T, E>>> as Try>::Residual, <Poll<Option<Result<T, E>>> as Try>::Output>
fn branch( self, ) -> ControlFlow<<Poll<Option<Result<T, E>>> as Try>::Residual, <Poll<Option<Result<T, E>>> 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<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: <Poll<Result<T, E>> as Try>::Output) -> Poll<Result<T, E>>
fn from_output(c: <Poll<Result<T, E>> as Try>::Output) -> Poll<Result<T, E>>
try_trait_v2
#84277)Output
type. Read moreSource§fn branch(
self,
) -> ControlFlow<<Poll<Result<T, E>> as Try>::Residual, <Poll<Result<T, E>> as Try>::Output>
fn branch( self, ) -> ControlFlow<<Poll<Result<T, E>> as Try>::Residual, <Poll<Result<T, E>> 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 moreimpl<T> Copy for Poll<T>where
T: Copy,
impl<T> StructuralPartialEq for Poll<T>
Auto Trait Implementations§
impl<T> Freeze for Poll<T>where
T: Freeze,
impl<T> RefUnwindSafe for Poll<T>where
T: RefUnwindSafe,
impl<T> Send for Poll<T>where
T: Send,
impl<T> Sync for Poll<T>where
T: Sync,
impl<T> Unpin for Poll<T>where
T: Unpin,
impl<T> UnwindSafe for Poll<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
sized_type_properties
)[Self]
. Read more