#async #ready_state #poll_ready

async-ready

Async readiness traits

6 stable releases

✓ Uses Rust 2018 edition

3.0.0 May 15, 2019
2.1.0 Apr 16, 2019
2.0.1 Apr 15, 2019
2.0.0 Mar 8, 2019
1.0.1 Mar 8, 2019

#76 in Asynchronous

Download history 1104/week @ 2019-11-01 1049/week @ 2019-11-08 1134/week @ 2019-11-15 880/week @ 2019-11-22 1222/week @ 2019-11-29 1664/week @ 2019-12-06 1119/week @ 2019-12-13 391/week @ 2019-12-20 440/week @ 2019-12-27 809/week @ 2020-01-03 1182/week @ 2020-01-10 1198/week @ 2020-01-17 1142/week @ 2020-01-24 316/week @ 2020-01-31 44/week @ 2020-02-07

4,581 downloads per month
Used in 10 crates (via romio)

MIT/Apache

14KB
104 lines

async-ready

crates.io version build status downloads docs.rs docs

Async readiness traits. Useful when implementing async state machines that can later be wrapped in dedicated futures.

Examples

Basic usage

#![feature(futures_api)]

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(()))
  }
}

Installation

$ cargo add async-ready

Safety

This crate uses #![deny(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

References

None.

License

MIT OR Apache-2.0

No runtime deps