pub trait PollExt<T> {
// Required methods
fn unwrap(self) -> T;
fn expect(self, msg: &str) -> T;
fn expect_pending(&self, msg: &str);
fn ready_or<E>(self, error: E) -> Result<T, E>;
fn ready_or_else<E, F>(self, error: F) -> Result<T, E>
where F: FnOnce() -> E;
}
Expand description
An extension trait for core::task::Poll
that provides convenient adapters for extracting
output values.
Required Methods§
Sourcefn expect(self, msg: &str) -> T
fn expect(self, msg: &str) -> T
Returns the value contained in a Poll::Ready value or panics with a custom message.
Sourcefn expect_pending(&self, msg: &str)
fn expect_pending(&self, msg: &str)
Expect a Poll to be Pending, or panics with a custom message.
Sourcefn ready_or<E>(self, error: E) -> Result<T, E>
fn ready_or<E>(self, error: E) -> Result<T, E>
Turns a Poll into a Result, mapping Poll::Ready(value) to Ok(value) and Poll::Pending to Err(error)
Sourcefn ready_or_else<E, F>(self, error: F) -> Result<T, E>where
F: FnOnce() -> E,
fn ready_or_else<E, F>(self, error: F) -> Result<T, E>where
F: FnOnce() -> E,
Turns a Poll into a Result, mapping Poll::Ready(value) to Ok(value) and Poll::Pending to Err(error())
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.