6 stable releases

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

#1940 in Asynchronous

Download history 122/week @ 2023-11-23 59/week @ 2023-11-30 96/week @ 2023-12-07 127/week @ 2023-12-14 100/week @ 2023-12-21 45/week @ 2023-12-28 74/week @ 2024-01-04 117/week @ 2024-01-11 98/week @ 2024-01-18 70/week @ 2024-01-25 46/week @ 2024-02-01 108/week @ 2024-02-08 146/week @ 2024-02-15 135/week @ 2024-02-22 148/week @ 2024-02-29 112/week @ 2024-03-07

561 downloads per month
Used in 12 crates (3 directly)

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