Skip to content

Rust: AsyncRead/AsyncWrite wrappers around Read/Write

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

sbillig/pseudo-async-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pseudo-async-io

Simple pseudo-async 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)
}

About

Rust: AsyncRead/AsyncWrite wrappers around Read/Write

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages