自己写的当Rust练习了,写的不咋地但是能用
use std::thread;
use std::result::Result;
use reqwest::Error as reqwest_err;
use reqwest::header::{HeaderMap, HeaderValue, IntoHeaderName};
use std::fs::{OpenOptions, create_dir_all};
use std::io::Write;
use std::sync::{Arc, Mutex};
fn main(){
let path_url:String = String::from("https://unpkg.com/browse/react@16.7.0/");
let file_url:String = String::from("https://unpkg.com/react@16.7.0/");
let file_path:String = String::from("./result/react@16.7.0");
let r = ReadTarget::new(path_url, file_url,file_path);
let mut i = r.scan_item().unwrap();
r.read_file(i);
}
pub struct ReadTarget {
path_url:String,
file_url:String,
file_path:String,
headers:HeaderMap<HeaderValue>,
max_task:usize
}
impl ReadTarget{
pub fn scan_item(&self) ->Result<Vec<String>,reqwest_err>{
let mut file_vec:Vec<String> = Ve