pub async fn read_exact_arc<R: AsyncRead>(
read: R,
len: usize,
) -> Result<Arc<[u8]>>
Available on crate features
io-util
and io
only.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]);