[−][src]Enum futures_polling::Polling
An enum similar to Poll
, but containing a future in its Pending
variant.
Example
use futures_lite::future; use futures_polling::{FuturePollingExt, Polling}; let mut polling = async { future::yield_now().await; 42 }.polling(); assert_eq!(polling.is_pending(), true); // Poll just once. polling.polling_once().await; assert_eq!(polling.is_pending(), true); // Poll until the inner future is ready. assert_eq!(polling.await, 42);
Variants
Ready(Fut::Output)
Contains the future's output once it has returned it (like Poll::Ready
).
Example
use futures_polling::{FuturePollingExt, Polling}; let mut polling = async { 42i32 }.polling(); polling.polling_once().await; if let Polling::Ready(out) = polling { assert_eq!(out, 42); } else { unreachable!(); } // or assert_eq!(polling.into_ready(), Some(42));
Contains the pending future.
Example
use futures_lite::future; use futures_polling::{FuturePollingExt, Polling}; let mut polling = async { future::yield_now().await; 42i32 }.polling(); if let Polling::Pending(_) = polling { // -> future::yield_now().await; polling.polling_once().await; } else { unreachable!(); } if let Polling::Pending(_) = polling { // 42 polling.polling_once().await; } else { unreachable!(); } assert_eq!(polling.into_ready(), Some(42));
The future has already returned an output, but it has already been extracted out of
Polling
.
Example
use futures_polling::{FuturePollingExt, Polling}; let mut polling = async { 42i32 }.polling(); polling.polling_once().await; assert_eq!(polling.take_ready(), Some(42)); assert_eq!(polling.is_done(), true);
Implementations
impl<Fut: Future> Polling<Fut>
[src]
pub fn into_ready(self) -> Option<Fut::Output>
[src]
self | return |
---|---|
Polling::Ready(out) | Some(out) |
Polling::Pending(_) | None |
Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.into_ready(), Some(42)); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.into_ready(), None); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.into_ready(), None);
pub fn into_pending(self) -> Option<Fut>
[src]
self | return |
---|---|
Polling::Ready(_) | None |
Polling::Pending(fut) | Some(fut) |
Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.into_pending().is_some(), false); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.into_pending().unwrap().await, 42); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.into_pending().is_some(), false);
pub fn into_poll(self) -> Poll<Fut::Output>
[src]
self | return |
---|---|
Polling::Ready(out) | Poll::Ready(out) |
Polling::Pending(_) | Poll::Pending |
Polling::Done | Poll::Pending |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.into_poll(), Poll::Ready(42)); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.into_poll(), Poll::Pending); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.into_poll(), Poll::Pending);
pub fn is_ready(&self) -> bool
[src]
Returns true
is self
is Polling::Ready(_)
.
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.is_ready(), true); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.is_ready(), false); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.is_ready(), false);
pub fn is_pending(&self) -> bool
[src]
Returns true
is self
is Polling::Pending(_)
.
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.is_pending(), false); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.is_pending(), true); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.is_pending(), false);
pub fn is_done(&self) -> bool
[src]
Returns true
is self
is Polling::Done
.
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.is_done(), false); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.is_done(), false); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.is_done(), true);
pub fn as_ready(&self) -> Option<&Fut::Output>
[src]
&self | return |
---|---|
Polling::Ready(out) | Some(&out) |
Polling::Pending(_) | None |
Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.as_ready(), Some(&42)); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.as_ready(), None); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.as_ready(), None);
pub fn as_pending(&self) -> Option<&Fut>
[src]
&self | return |
---|---|
Polling::Ready(_) | None |
Polling::Pending(fut) | Some(&fut) |
Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.as_pending().is_some(), false); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.as_pending().is_some(), true); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.as_pending().is_some(), false);
pub fn as_poll(&self) -> Poll<&Fut::Output>
[src]
&self | return |
---|---|
Polling::Ready(out) | Poll::Ready(&out) |
Polling::Pending(_) | Poll::Pending |
Polling::Done | Poll::Pending |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.as_poll(), Poll::Ready(&42)); let polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.as_poll(), Poll::Pending); let polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.as_poll(), Poll::Pending);
pub fn as_ready_mut(&mut self) -> Option<&mut Fut::Output>
[src]
&mut self | return |
---|---|
Polling::Ready(out) | Some(&mut out) |
Polling::Pending(_) | None |
Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); if let Some(out) = polling.as_ready_mut() { assert_eq!(*out, 42); *out = 0; } else { unreachable!(); } assert_eq!(polling.as_ready(), Some(&0)); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.as_ready_mut(), None); let mut polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.as_ready_mut(), None);
pub fn as_pending_mut(&mut self) -> Option<&mut Fut>
[src]
&mut self | return |
---|---|
Polling::Ready(_) | None |
Polling::Pending(fut) | Some(&mut fut) |
Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.as_pending_mut().is_some(), false); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.as_pending_mut().unwrap().await, 42); let mut polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.as_pending_mut().is_some(), false);
pub fn as_poll_mut(&mut self) -> Poll<&mut Fut::Output>
[src]
&mut self | return |
---|---|
Polling::Ready(out) | Poll::Ready(&mut out) |
Polling::Pending(_) | Poll::Pending |
Polling::Done | Poll::Pending |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); if let Poll::Ready(out) = polling.as_poll_mut() { *out = 0; } else { unreachable!(); } assert_eq!(polling.as_poll(), Poll::Ready(&0)); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.as_poll_mut(), Poll::Pending); let mut polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.as_poll_mut(), Poll::Pending);
pub fn replace(&mut self, with: Self) -> Self
[src]
Moves with
into &mut self
and returns the previous self
.
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut p1 = Polling::<Ready<i32>>::Ready(42); let p2 = Polling::<Ready<i32>>::Ready(24); let p3 = p1.replace(p2); assert_eq!(p1.as_ready(), Some(&24)); assert_eq!(p3.as_ready(), Some(&42));
pub fn take(&mut self) -> Polling<Fut>ⓘ
[src]
Takes the output or future out of self
, leaving Polling::Done
in its place.
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.take().into_ready(), Some(42)); assert_eq!(polling.into_ready(), None); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.take().into_pending().unwrap().await, 42); assert_eq!(polling.into_pending().is_some(), false); let mut polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.take().is_done(), true); assert_eq!(polling.is_done(), true);
pub fn take_ready(&mut self) -> Option<Fut::Output>
[src]
&mut self | new self value | return |
---|---|---|
Polling::Ready(out) | Polling::Done | Some(out) |
Polling::Pending(fut) | Polling::Pending(fut) | None |
Polling::Done | Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.take_ready(), Some(42)); assert_eq!(polling.into_ready(), None); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.take_ready(), None); assert_eq!(polling.into_pending().unwrap().await, 42); let mut polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.take_ready(), None); assert_eq!(polling.is_done(), true);
pub fn take_pending(&mut self) -> Option<Fut>
[src]
&mut self | new self value | return |
---|---|---|
Polling::Ready(out) | Polling::Ready(out) | None |
Polling::Pending(fut) | Polling::Done | Some(fut) |
Polling::Done | Polling::Done | None |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.take_pending().is_some(), false); assert_eq!(polling.into_ready(), Some(42)); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.take_pending().unwrap().await, 42); assert_eq!(polling.into_pending().is_some(), false); let mut polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.take_pending().is_some(), false); assert_eq!(polling.is_done(), true);
pub fn take_poll(&mut self) -> Poll<Fut::Output>
[src]
&mut self | new self value | return |
---|---|---|
Polling::Ready(out) | Polling::Done | Poll::Ready(out) |
Polling::Pending(fut) | Polling::Pending(fut) | Poll::Pending |
Polling::Done | Polling::Done | Poll::Pending |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.take_poll(), Poll::Ready(42)); assert_eq!(polling.into_ready(), None); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.take_poll(), Poll::Pending); assert_eq!(polling.into_pending().unwrap().await, 42); let mut polling = Polling::<Ready<i32>>::Done; assert_eq!(polling.take_poll(), Poll::Pending); assert_eq!(polling.is_done(), true);
pub async fn poll_once<'_>(&'_ mut self) -> Poll<Fut::Output>
[src]
&mut self | fut.poll(_) | new self value | return |
---|---|---|---|
Polling::Ready(out) | x | Polling::Done | Poll::Ready(out) |
Polling::Pending(fut) | Poll::Ready(out) | Polling::Done | Poll::Ready(out) |
Polling::Pending(fut) | Poll::Pending | Polling::Pending(fut) | Poll::Pending |
Polling::Done | x | panic!() | panic!() |
Example
use core::task::Poll; use futures_lite::future::{self, Pending, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); assert_eq!(polling.poll_once().await, Poll::Ready(42)); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); assert_eq!(polling.poll_once().await, Poll::Ready(42)); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Pending<i32>>::Pending(future::pending()); assert_eq!(polling.poll_once().await, Poll::Pending); assert_eq!(polling.is_done(), false);
pub async fn polling_once<'_, '_>(&'_ mut self) -> &'_ mut Self
[src]
&mut self | fut.poll(_) | new self value |
---|---|---|
Polling::Ready(out) | x | Polling::Ready(out) |
Polling::Pending(fut) | Poll::Ready(out) | Polling::Ready(out) |
Polling::Pending(fut) | Poll::Pending | Polling::Pending(fut) |
Polling::Done | x | panic!() |
Example
use core::task::Poll; use futures_lite::future::{self, Pending, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<i32>>::Ready(42); polling.polling_once().await; assert_eq!(polling.take_poll(), Poll::Ready(42)); let mut polling = Polling::<Ready<i32>>::Pending(future::ready(42)); polling.polling_once().await; assert_eq!(polling.take_poll(), Poll::Ready(42)); let mut polling = Polling::<Pending<i32>>::Pending(future::pending()); polling.polling_once().await; assert_eq!(polling.is_pending(), true);
impl<T, E, Fut: Future<Output = Result<T, E>>> Polling<Fut>
[src]
pub fn try_into_ready(self) -> Result<Option<T>, E>
[src]
self | return |
---|---|
Polling::Ready(Ok(ok)) | Ok(Some(ok)) |
Polling::Ready(Err(err)) | Err(err) |
Polling::Pending(_) | Ok(None) |
Polling::Done | Ok(None) |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(polling.try_into_ready(), Ok(Some(42))); let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(polling.try_into_ready(), Err(42)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_into_ready(), Ok(None)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_into_ready(), Ok(None)); let polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_into_ready(), Ok(None));
pub fn try_into_poll(self) -> Result<Poll<T>, E>
[src]
self | return |
---|---|
Polling::Ready(Ok(ok)) | Ok(Poll::Ready(ok)) |
Polling::Ready(Err(err)) | Err(err) |
Polling::Pending(_) | Ok(Poll::Pending) |
Polling::Done | Ok(Poll::Pending) |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(polling.try_into_poll(), Ok(Poll::Ready(42))); let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(polling.try_into_poll(), Err(42)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_into_poll(), Ok(Poll::Pending)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_into_poll(), Ok(Poll::Pending)); let polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_into_poll(), Ok(Poll::Pending));
pub fn try_as_ready(&self) -> Result<Option<&T>, &E>
[src]
&self | return |
---|---|
Polling::Ready(Ok(ok)) | Ok(Some(&ok)) |
Polling::Ready(Err(Err)) | Err(&err) |
Polling::Pending(_) | Ok(None) |
Polling::Done | Ok(None) |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(polling.try_as_ready(), Ok(Some(&42))); let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(polling.try_as_ready(), Err(&42)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_as_ready(), Ok(None)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_as_ready(), Ok(None)); let polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_as_ready(), Ok(None));
pub fn try_as_poll(&self) -> Result<Poll<&T>, &E>
[src]
&self | return |
---|---|
Polling::Ready(Ok(ok)) | Ok(Poll::Ready(&ok)) |
Polling::Ready(Err(Err)) | Err(&mut err) |
Polling::Pending(_) | Ok(Poll::Pending) |
Polling::Done | Ok(Poll::Pending) |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(polling.try_as_poll(), Ok(Poll::Ready(&42))); let polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(polling.try_as_poll(), Err(&42)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_as_poll(), Ok(Poll::Pending)); let polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_as_poll(), Ok(Poll::Pending)); let polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_as_poll(), Ok(Poll::Pending));
pub fn try_as_ready_mut(&mut self) -> Result<Option<&mut T>, &mut E>
[src]
&mut self | return |
---|---|
Polling::Ready(Ok(ok)) | Ok(Some(&mut ok)) |
Polling::Ready(Err(Err)) | Err(&mut err) |
Polling::Pending(_) | Ok(None) |
Polling::Done | Ok(None) |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); if let Ok(Some(ok)) = polling.try_as_ready_mut() { assert_eq!(*ok, 42); *ok = 0; } else { unreachable!(); } assert_eq!(polling.try_as_ready(), Ok(Some(&0))); let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); if let Err(err) = polling.try_as_ready_mut() { assert_eq!(*err, 42); *err = 0; } else { unreachable!(); } assert_eq!(polling.try_as_ready(), Err(&0)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_as_ready_mut(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_as_ready_mut(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_as_ready_mut(), Ok(None));
pub fn try_as_poll_mut(&mut self) -> Result<Poll<&mut T>, &mut E>
[src]
&mut self | return |
---|---|
Polling::Ready(Ok(ok)) | Ok(Poll::Ready(&mut ok)) |
Polling::Ready(Err(Err)) | Err(&mut err) |
Polling::Pending(_) | Ok(Poll::Pending) |
Polling::Done | Ok(Poll::Pending) |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); if let Ok(Poll::Ready(ok)) = polling.try_as_poll_mut() { assert_eq!(*ok, 42); *ok = 0; } else { unreachable!(); } assert_eq!(polling.try_as_poll(), Ok(Poll::Ready(&0))); let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); if let Err(err) = polling.try_as_poll_mut() { assert_eq!(*err, 42); *err = 0; } else { unreachable!(); } assert_eq!(polling.try_as_poll(), Err(&0)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_as_poll_mut(), Ok(Poll::Pending)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_as_poll_mut(), Ok(Poll::Pending)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_as_poll_mut(), Ok(Poll::Pending));
pub fn try_take_ready(&mut self) -> Result<Option<T>, E>
[src]
&mut self | new self value | return |
---|---|---|
Polling::Ready(Ok(ok)) | Polling::Done | Ok(Some(ok)) |
Polling::Ready(Err(err)) | Polling::Done | Err(err) |
Polling::Pending(fut) | Polling::Pending(fut) | Ok(None) |
Polling::Done | Polling::Done | Ok(None) |
Example
use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(polling.try_take_ready(), Ok(Some(42))); assert_eq!(polling.try_into_ready(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(polling.try_take_ready(), Err(42)); assert_eq!(polling.try_into_ready(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_take_ready(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_take_ready(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_take_ready(), Ok(None));
pub fn try_take_poll(&mut self) -> Result<Poll<T>, E>
[src]
&mut self | new self value | return |
---|---|---|
Polling::Ready(Ok(ok)) | Polling::Done | Ok(Poll::Ready(ok)) |
Polling::Ready(Err(err)) | Polling::Done | Err(err) |
Polling::Pending(fut) | Polling::Pending(fut) | Ok(Poll::Pending) |
Polling::Done | Polling::Done | Ok(Poll::Pending) |
Example
use core::task::Poll; use futures_lite::future::{self, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(polling.try_take_poll(), Ok(Poll::Ready(42))); assert_eq!(polling.try_into_ready(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(polling.try_take_poll(), Err(42)); assert_eq!(polling.try_into_ready(), Ok(None)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_take_poll(), Ok(Poll::Pending)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_take_poll(), Ok(Poll::Pending)); let mut polling = Polling::<Ready<Result<i32, i32>>>::Done; assert_eq!(polling.try_take_poll(), Ok(Poll::Pending));
pub fn try_poll(
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Result<Poll<T>, E>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Result<Poll<T>, E>
&mut self | fut.poll(ctx) | new self value | return |
---|---|---|---|
Polling::Ready(Ok(ok)) | x | Polling::Done | Ok(Poll:Ready(ok)) |
Polling::Ready(Err(err)) | x | Polling::Done | Err(err) |
Polling::Pending(fut) | Poll::Ready(Ok(ok)) | Polling::Done | Ok(Poll::Ready(ok)) |
Polling::Pending(fut) | Poll::Ready(Err(err)) | Polling::Done | Err(err) |
Polling::Pending(fut) | Poll::Pending | Polling::Pending(fut) | Ok(Poll::Pending) |
Polling::Done | x | panic!() | panic!() |
Example
use core::pin::Pin; use core::task::Poll; use futures_lite::future::{self, Pending, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(Pin::new(&mut polling).try_poll(ctx), Ok(Poll::Ready(42))); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(Pin::new(&mut polling).try_poll(ctx), Err(42)); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(Pin::new(&mut polling).try_poll(ctx), Ok(Poll::Ready(42))); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(Pin::new(&mut polling).try_poll(ctx), Err(42)); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Pending<Result<i32, i32>>>::Pending(future::pending()); assert_eq!(Pin::new(&mut polling).try_poll(ctx), Ok(Poll::Pending)); assert_eq!(polling.is_done(), false);
pub async fn try_poll_once<'_>(&'_ mut self) -> Result<Poll<T>, E>
[src]
&mut self | fut.poll(_) | new self value | return |
---|---|---|---|
Polling::Ready(Ok(ok)) | x | Polling::Done | Ok(Poll:Ready(ok)) |
Polling::Ready(Err(err)) | x | Polling::Done | Err(err) |
Polling::Pending(fut) | Poll::Ready(Ok(ok)) | Polling::Done | Ok(Poll::Ready(ok)) |
Polling::Pending(fut) | Poll::Ready(Err(err)) | Polling::Done | Err(err) |
Polling::Pending(fut) | Poll::Pending | Polling::Pending(fut) | Ok(Poll::Pending) |
Polling::Done | x | panic!() | panic!() |
Example
use core::task::Poll; use futures_lite::future::{self, Pending, Ready}; use futures_polling::Polling; let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Ok(42)); assert_eq!(polling.try_poll_once().await, Ok(Poll::Ready(42))); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Ready<Result<i32, i32>>>::Ready(Err(42)); assert_eq!(polling.try_poll_once().await, Err(42)); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Ok(42))); assert_eq!(polling.try_poll_once().await, Ok(Poll::Ready(42))); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Ready<Result<i32, i32>>>::Pending(future::ready(Err(42))); assert_eq!(polling.try_poll_once().await, Err(42)); assert_eq!(polling.is_done(), true); let mut polling = Polling::<Pending<Result<i32, i32>>>::Pending(future::pending()); assert_eq!(polling.try_poll_once().await, Ok(Poll::Pending)); assert_eq!(polling.is_done(), false);
Trait Implementations
impl<Fut: Clone + Future> Clone for Polling<Fut> where
Fut::Output: Clone,
[src]
Fut::Output: Clone,
impl<Fut: Copy + Future> Copy for Polling<Fut> where
Fut::Output: Copy,
[src]
Fut::Output: Copy,
impl<Fut: Debug + Future> Debug for Polling<Fut> where
Fut::Output: Debug,
[src]
Fut::Output: Debug,
impl<Fut: Eq + Future> Eq for Polling<Fut> where
Fut::Output: Eq,
[src]
Fut::Output: Eq,
impl<Fut: Future> From<Fut> for Polling<Fut>
[src]
impl<Fut: Future> Future for Polling<Fut>
[src]
type Output = Fut::Output
The type of value produced on completion.
fn poll(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Self::Output>
[src]
impl<Fut: Hash + Future> Hash for Polling<Fut> where
Fut::Output: Hash,
[src]
Fut::Output: Hash,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<Fut: Ord + Future> Ord for Polling<Fut> where
Fut::Output: Ord,
[src]
Fut::Output: Ord,
fn cmp(&self, other: &Polling<Fut>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<Fut: PartialEq + Future> PartialEq<Polling<Fut>> for Polling<Fut> where
Fut::Output: PartialEq,
[src]
Fut::Output: PartialEq,
impl<Fut: PartialOrd + Future> PartialOrd<Polling<Fut>> for Polling<Fut> where
Fut::Output: PartialOrd,
[src]
Fut::Output: PartialOrd,
fn partial_cmp(&self, other: &Polling<Fut>) -> Option<Ordering>
[src]
fn lt(&self, other: &Polling<Fut>) -> bool
[src]
fn le(&self, other: &Polling<Fut>) -> bool
[src]
fn gt(&self, other: &Polling<Fut>) -> bool
[src]
fn ge(&self, other: &Polling<Fut>) -> bool
[src]
impl<Fut: Future> StructuralEq for Polling<Fut>
[src]
impl<Fut: Future> StructuralPartialEq for Polling<Fut>
[src]
Auto Trait Implementations
impl<Fut> RefUnwindSafe for Polling<Fut> where
Fut: RefUnwindSafe,
<Fut as Future>::Output: RefUnwindSafe,
Fut: RefUnwindSafe,
<Fut as Future>::Output: RefUnwindSafe,
impl<Fut> Send for Polling<Fut> where
Fut: Send,
<Fut as Future>::Output: Send,
Fut: Send,
<Fut as Future>::Output: Send,
impl<Fut> Sync for Polling<Fut> where
Fut: Sync,
<Fut as Future>::Output: Sync,
Fut: Sync,
<Fut as Future>::Output: Sync,
impl<Fut> Unpin for Polling<Fut> where
Fut: Unpin,
<Fut as Future>::Output: Unpin,
Fut: Unpin,
<Fut as Future>::Output: Unpin,
impl<Fut> UnwindSafe for Polling<Fut> where
Fut: UnwindSafe,
<Fut as Future>::Output: UnwindSafe,
Fut: UnwindSafe,
<Fut as Future>::Output: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<Fut> FuturePollingExt for Fut where
Fut: Future,
[src]
Fut: Future,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,