From 0e0714f7cdf29c31d10decf154a80052a22135be Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 12 Jan 2020 22:19:14 +0800 Subject: [PATCH] add read_to_bytes --- Cargo.toml | 3 ++- src/util_io.rs | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ce44839..f249096 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "rust_util" -version = "0.2.0" +version = "0.2.1" authors = ["Hatter Jiang "] edition = "2018" description = "Hatter's Rust Util" license = "MIT" +readme = "README.md" [dependencies] libc = "0.2.65" diff --git a/src/util_io.rs b/src/util_io.rs index 4a1a35d..9cc55d0 100644 --- a/src/util_io.rs +++ b/src/util_io.rs @@ -20,6 +20,12 @@ pub fn read_to_string(read: &mut dyn Read) -> XResult { Ok(buffer) } +pub fn read_to_bytes(read: &mut dyn Read) -> XResult> { + let mut buffer = vec![]; + read.read_to_end(&mut buffer)?; + Ok(buffer) +} + pub fn copy_io(reader: &mut R, writer: &mut W, total: i64) -> io::Result where R: io::Read, W: io::Write { copy_io_with_head(reader, writer, total, "Downloading")