Enum Polling Copy item path Source pub enum Polling<Fut: Future > {
Ready(Fut::Output ),
Pending(Fut),
Done,
}Expand description 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 );
polling.polling_once().await ;
assert_eq! (polling.is_pending(), true );
assert_eq! (polling.await , 42 );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! ();
}
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 {
polling.polling_once().await ;
} else {
unreachable! ();
}
if let Polling::Pending(_ ) = polling {
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 );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 );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 );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);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 );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 );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 );&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 );&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 );&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);&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 );&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 );&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);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 ));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 );&mut selfnew self value return
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 );&mut selfnew self value return
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 );&mut selfnew self value return
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 );&mut selffut.poll(_)new self value return
Polling::Ready(out)x Polling::DonePoll::Ready(out)
Polling::Pending(fut)Poll::Ready(out)Polling::DonePoll::Ready(out)
Polling::Pending(fut)Poll::PendingPolling::Pending(fut)Poll::Pending
Polling::Donex 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 );&mut selffut.poll(_)new self value
Polling::Ready(out)x Polling::Ready(out)
Polling::Pending(fut)Poll::Ready(out)Polling::Ready(out)
Polling::Pending(fut)Poll::PendingPolling::Pending(fut)
Polling::Donex 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 );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 ));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));&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 ));&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));&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 ));&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));&mut selfnew self value return
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 ));&mut selfnew self value return
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));&mut selffut.poll(ctx)new self value return
Polling::Ready(Ok(ok))x Polling::DoneOk(Poll:Ready(ok))
Polling::Ready(Err(err))x Polling::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::Donex 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 );&mut selffut.poll(_)new self value return
Polling::Ready(Ok(ok))x Polling::DoneOk(Poll:Ready(ok))
Polling::Ready(Err(err))x Polling::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::Donex 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 );Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Converts to this type from the input type.
The type of value produced on completion.
Attempts to resolve the future to a final value, registering
the current task for wakeup if the value is not yet available.
Read more Compares and returns the maximum of two values.
Read more Compares and returns the minimum of two values.
Read more Restrict a value to a certain interval.
Read more Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
This method returns an ordering between
self and
other values if one exists.
Read more Tests less than (for
self and
other) and is used by the
< operator.
Read more Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more Tests greater than (for
self and
other) and is used by the
>
operator.
Read more Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Returns [
Polling::Pending(self)], consuming
self.
Read more Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The output that the future will produce on completion.
Which kind of future are we turning this into?
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.