1
0
mirror of https://github.com/jht5945/rust_util.git synced 2025-12-27 07:30:05 +08:00

add read_to_string

This commit is contained in:
2019-08-31 15:04:32 +08:00
parent b15ea1aa7b
commit c969e39efe

View File

@@ -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<String> {
let mut buffer = String::new();
read.read_to_string(&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")