Function compio_io::util::null

source ·
pub fn null() -> Null
Expand description

Create a new Null reader and writer which acts like a black hole.

All reads from and writes to this reader will return BufResult(Ok(0), buf) and leave the buffer unchanged.

§Examples

use compio_io::{null, AsyncRead, AsyncWrite};

let mut buf = Vec::with_capacity(10);
let mut null = null();

let (num_read, buf) = null.read(buf).await.unwrap();

assert_eq!(num_read, 0);
assert!(buf.is_empty());

let (num_written, buf) = null.write(buf).await.unwrap();
assert_eq!(num_written, 0);