[][src]Enum futures_polling::Polling

pub enum Polling<Fut: Future> {
    Ready(Fut::Output),
    Pending(Fut),
    Done,
}

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));
Pending(Fut)

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));
Done

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]

selfreturn
Polling::Ready(out)Some(out)
Polling::Pending(_)None
Polling::DoneNone

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]

selfreturn
Polling::Ready(_)None
Polling::Pending(fut)Some(fut)
Polling::DoneNone

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]

selfreturn
Polling::Ready(out)Poll::Ready(out)
Polling::Pending(_)Poll::Pending
Polling::DonePoll::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]

&selfreturn
Polling::Ready(out)Some(&out)
Polling::Pending(_)None
Polling::DoneNone

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]

&selfreturn
Polling::Ready(_)None
Polling::Pending(fut)Some(&fut)
Polling::DoneNone

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]

&selfreturn
Polling::Ready(out)Poll::Ready(&out)
Polling::Pending(_)Poll::Pending
Polling::DonePoll::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 selfreturn
Polling::Ready(out)Some(&mut out)
Polling::Pending(_)None
Polling::DoneNone

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 selfreturn
Polling::Ready(_)None
Polling::Pending(fut)Some(&mut fut)
Polling::DoneNone

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 selfreturn
Polling::Ready(out)Poll::Ready(&mut out)
Polling::Pending(_)Poll::Pending
Polling::DonePoll::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>

Notable traits for Polling<Fut>

impl<Fut: Future> Future for Polling<Fut> type Output = Fut::Output;
[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 selfnew self valuereturn
Polling::Ready(out)Polling::DoneSome(out)
Polling::Pending(fut)Polling::Pending(fut)None
Polling::DonePolling::DoneNone

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 selfnew self valuereturn
Polling::Ready(out)Polling::Ready(out)None
Polling::Pending(fut)Polling::DoneSome(fut)
Polling::DonePolling::DoneNone

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 selfnew self valuereturn
Polling::Ready(out)Polling::DonePoll::Ready(out)
Polling::Pending(fut)Polling::Pending(fut)Poll::Pending
Polling::DonePolling::DonePoll::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 selffut.poll(_)new self valuereturn
Polling::Ready(out)xPolling::DonePoll::Ready(out)
Polling::Pending(fut)Poll::Ready(out)Polling::DonePoll::Ready(out)
Polling::Pending(fut)Poll::PendingPolling::Pending(fut)Poll::Pending
Polling::Donexpanic!()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 selffut.poll(_)new self value
Polling::Ready(out)xPolling::Ready(out)
Polling::Pending(fut)Poll::Ready(out)Polling::Ready(out)
Polling::Pending(fut)Poll::PendingPolling::Pending(fut)
Polling::Donexpanic!()

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]

selfreturn
Polling::Ready(Ok(ok))Ok(Some(ok))
Polling::Ready(Err(err))Err(err)
Polling::Pending(_)Ok(None)
Polling::DoneOk(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]

selfreturn
Polling::Ready(Ok(ok))Ok(Poll::Ready(ok))
Polling::Ready(Err(err))Err(err)
Polling::Pending(_)Ok(Poll::Pending)
Polling::DoneOk(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]

&selfreturn
Polling::Ready(Ok(ok))Ok(Some(&ok))
Polling::Ready(Err(Err))Err(&err)
Polling::Pending(_)Ok(None)
Polling::DoneOk(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]

&selfreturn
Polling::Ready(Ok(ok))Ok(Poll::Ready(&ok))
Polling::Ready(Err(Err))Err(&mut err)
Polling::Pending(_)Ok(Poll::Pending)
Polling::DoneOk(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 selfreturn
Polling::Ready(Ok(ok))Ok(Some(&mut ok))
Polling::Ready(Err(Err))Err(&mut err)
Polling::Pending(_)Ok(None)
Polling::DoneOk(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 selfreturn
Polling::Ready(Ok(ok))Ok(Poll::Ready(&mut ok))
Polling::Ready(Err(Err))Err(&mut err)
Polling::Pending(_)Ok(Poll::Pending)
Polling::DoneOk(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 selfnew self valuereturn
Polling::Ready(Ok(ok))Polling::DoneOk(Some(ok))
Polling::Ready(Err(err))Polling::DoneErr(err)
Polling::Pending(fut)Polling::Pending(fut)Ok(None)
Polling::DonePolling::DoneOk(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 selfnew self valuereturn
Polling::Ready(Ok(ok))Polling::DoneOk(Poll::Ready(ok))
Polling::Ready(Err(err))Polling::DoneErr(err)
Polling::Pending(fut)Polling::Pending(fut)Ok(Poll::Pending)
Polling::DonePolling::DoneOk(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]

&mut selffut.poll(ctx)new self valuereturn
Polling::Ready(Ok(ok))xPolling::DoneOk(Poll:Ready(ok))
Polling::Ready(Err(err))xPolling::DoneErr(err)
Polling::Pending(fut)Poll::Ready(Ok(ok))Polling::DoneOk(Poll::Ready(ok))
Polling::Pending(fut)Poll::Ready(Err(err))Polling::DoneErr(err)
Polling::Pending(fut)Poll::PendingPolling::Pending(fut)Ok(Poll::Pending)
Polling::Donexpanic!()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 selffut.poll(_)new self valuereturn
Polling::Ready(Ok(ok))xPolling::DoneOk(Poll:Ready(ok))
Polling::Ready(Err(err))xPolling::DoneErr(err)
Polling::Pending(fut)Poll::Ready(Ok(ok))Polling::DoneOk(Poll::Ready(ok))
Polling::Pending(fut)Poll::Ready(Err(err))Polling::DoneErr(err)
Polling::Pending(fut)Poll::PendingPolling::Pending(fut)Ok(Poll::Pending)
Polling::Donexpanic!()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]

impl<Fut: Copy + Future> Copy for Polling<Fut> where
    Fut::Output: Copy
[src]

impl<Fut: Debug + Future> Debug for Polling<Fut> where
    Fut::Output: Debug
[src]

impl<Fut: Eq + Future> Eq for Polling<Fut> where
    Fut::Output: Eq
[src]

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.

impl<Fut: Hash + Future> Hash for Polling<Fut> where
    Fut::Output: Hash
[src]

impl<Fut: Ord + Future> Ord for Polling<Fut> where
    Fut::Output: Ord
[src]

impl<Fut: PartialEq + Future> PartialEq<Polling<Fut>> for Polling<Fut> where
    Fut::Output: PartialEq
[src]

impl<Fut: PartialOrd + Future> PartialOrd<Polling<Fut>> for Polling<Fut> where
    Fut::Output: PartialOrd
[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

impl<Fut> Send for Polling<Fut> where
    Fut: Send,
    <Fut as Future>::Output: Send

impl<Fut> Sync for Polling<Fut> where
    Fut: Sync,
    <Fut as Future>::Output: Sync

impl<Fut> Unpin for Polling<Fut> where
    Fut: Unpin,
    <Fut as Future>::Output: Unpin

impl<Fut> UnwindSafe for Polling<Fut> where
    Fut: UnwindSafe,
    <Fut as Future>::Output: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<Fut> FuturePollingExt for Fut where
    Fut: Future
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.