pseudo-async-io

Crates.iopseudo-async-io
lib.rspseudo-async-io
version0.1.0
sourcesrc
created_at2019-03-05 05:54:13.34535
updated_at2019-03-05 05:54:13.34535
descriptionSimple (pseudo-) async wrappers around Read and Write
homepage
repositoryhttps://github.com/sbillig/pseudo-async-io
max_upload_size
id118819
size17,119
Sean Billig (sbillig)

documentation

https://docs.rs/pseudo-async-io/

README

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)
}
Commit count: 3

cargo fmt