Expand description
Async readiness traits. Useful when implementing async state machines that can later be wrapped in dedicated futures.
§Example
use std::pin::Pin;
use std::task::{Context, Poll};
use futures::prelude::*;
use async_ready::AsyncReady;
use std::io;
struct Fut;
impl Future for Fut {
type Output = ();
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(())
}
}
impl AsyncReady for Fut {
type Ok = ();
type Err = io::Error;
fn poll_ready(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Self::Ok, Self::Err>> {
Poll::Ready(Ok(()))
}
}
Traits§
- Async
Read Ready - Determine if the underlying API can be read from.
- Async
Ready - Determine if a struct is async-ready to yield futures.
- Async
Write Ready - Determine if the underlying API can be written to.
- Take
Error - Extract an error from the underlying struct that isn’t propagated through regular channels.