compio_io::util

Function 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::{AsyncRead, AsyncWrite, null};

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);