1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 15:40:03 +08:00

add read_to_bytes

This commit is contained in:
2020-01-12 22:19:14 +08:00
parent 53747a2337
commit 0e0714f7cd
2 changed files with 8 additions and 1 deletions

View File

@@ -20,6 +20,12 @@ pub fn read_to_string(read: &mut dyn Read) -> XResult<String> {
Ok(buffer)
}
pub fn read_to_bytes(read: &mut dyn Read) -> XResult<Vec<u8>> {
let mut buffer = vec![];
read.read_to_end(&mut buffer)?;
Ok(buffer)
}
pub fn copy_io<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W, total: i64) -> io::Result<u64>
where R: io::Read, W: io::Write {
copy_io_with_head(reader, writer, total, "Downloading")