diff --git a/src/util_io.rs b/src/util_io.rs index d0f98da..4a1a35d 100644 --- a/src/util_io.rs +++ b/src/util_io.rs @@ -1,15 +1,25 @@ use std::{ - io::{self, ErrorKind}, + io::{self, + ErrorKind, + prelude::*, + }, time::{SystemTime, Duration}, }; +use super::XResult; use super::util_size::get_display_size; use super::util_msg::print_lastline; pub const DEFAULT_BUF_SIZE: usize = 8 * 1024; +pub fn read_to_string(read: &mut dyn Read) -> XResult { + let mut buffer = String::new(); + read.read_to_string(&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")