Crates.io | async-ready |
lib.rs | async-ready |
version | 3.0.0 |
source | src |
created_at | 2019-03-08 00:28:50.262903 |
updated_at | 2019-05-15 17:47:17.124599 |
description | Async readiness traits. |
homepage | |
repository | https://github.com/rustasync/async-ready |
max_upload_size | |
id | 119399 |
size | 39,313 |
Async readiness traits. Useful when implementing async state machines that can later be wrapped in dedicated futures.
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(()))
}
}
$ cargo add async-ready
This crate uses #![deny(unsafe_code)]
to ensure everything is implemented in
100% Safe Rust.
Want to join us? Check out our "Contributing" guide and take a look at some of these issues:
None.
MIT OR Apache-2.0