1 unstable release
0.1.0 | Mar 5, 2019 |
---|
#472 in #read-write
7KB
60 lines
pseudo-async-io
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)
}
Dependencies
~1MB
~17K SLoC