ctoolbox/utilities/
reader.rs

1//! Utilities for working with streams.
2
3use anyhow::Result;
4
5/// Reads all bytes from a stream into a buffer.
6/// Returns an error if any chunk fails.
7pub fn reader_to_bytes<R>(mut reader: R) -> Result<Vec<u8>>
8where
9    R: std::io::Read + Send + 'static,
10{
11    let mut buffer = Vec::new();
12    reader.read_to_end(&mut buffer)?;
13    Ok(buffer)
14}