Crates.io | pseudo-async-io |
lib.rs | pseudo-async-io |
version | 0.1.0 |
source | src |
created_at | 2019-03-05 05:54:13.34535 |
updated_at | 2019-03-05 05:54:13.34535 |
description | Simple (pseudo-) async wrappers around Read and Write |
homepage | |
repository | https://github.com/sbillig/pseudo-async-io |
max_upload_size | |
id | 118819 |
size | 17,119 |
Simple (pseudo-)AsyncRead/AsyncWrite wrappers around the Read and Write traits.
For futures-0.3; Requires nightly rust.
#![feature(async_await, await_macro, futures_api)]
use std::io::Cursor;
use futures::{
io::AsyncReadExt,
io::AsyncWriteExt,
io::Error,
future::FutureExt,
executor::block_on,
};
use pseudo_async_io;
async fn do_some_io() -> Result<Vec<u8>, Error> {
let mut w = pseudo_async_io::wrap(Cursor::new(vec![1; 6]));
await!(w.write_all(&[1, 2, 3]))?;
let mut tmp = vec![0; 4];
await!(w.read(&mut tmp))?;
Ok(tmp)
}