Function read_exact_arc

pub async fn read_exact_arc<R>(read: R, len: usize) -> Result<Arc<[u8]>, Error>
where R: AsyncRead,
Expand description

Read data from an AsyncRead into an Arc.

This uses Arc::new_uninit_slice and reads into the resulting uninitialized Arc.

ยงExample

use tokio_util::io::read_exact_arc;

let read = tokio::io::repeat(42);

let arc = read_exact_arc(read, 4).await?;

assert_eq!(&arc[..], &[42; 4]);