async_utils::traits

Trait PollExt

Source
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§

Source

fn unwrap(self) -> T

Returns the value contained in a Poll::Ready value or panics.

Source

fn expect(self, msg: &str) -> T

Returns the value contained in a Poll::Ready value or panics with a custom message.

Source

fn expect_pending(&self, msg: &str)

Expect a Poll to be Pending, or panics with a custom message.

Source

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)

Source

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.

Implementations on Foreign Types§

Source§

impl<T> PollExt<T> for Poll<T>

Source§

fn unwrap(self) -> T

Source§

fn expect(self, msg: &str) -> T

Source§

fn expect_pending(&self, msg: &str)

Source§

fn ready_or<E>(self, error: E) -> Result<T, E>

Source§

fn ready_or_else<E, F>(self, error: F) -> Result<T, E>
where F: FnOnce() -> E,

Implementors§