diff --git a/src/lib.rs b/src/lib.rs index 35742ba..0fef5ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -607,7 +607,8 @@ pub struct Download { show_progress: bool, url: String, headers: reqwest::header::HeaderMap, - progress_style: ProgressStyle, + progress_template: String, + progress_chars: String, } impl Download { /// Specify download url @@ -616,9 +617,8 @@ impl Download { show_progress: false, url: url.to_owned(), headers: reqwest::header::HeaderMap::new(), - progress_style: ProgressStyle::default_bar() - .template("[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}") - .progress_chars("=>-"), + progress_template: "[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}".to_string(), + progress_chars: "=>-".to_string(), } } @@ -629,8 +629,9 @@ impl Download { } /// Set the progress style - pub fn set_progress_style(&mut self, progress_style: ProgressStyle) -> &mut Self { - self.progress_style = progress_style; + pub fn set_progress_style(&mut self, progress_template: String, progress_chars: String) -> &mut Self { + self.progress_template = progress_template; + self.progress_chars = progress_chars; self } @@ -699,7 +700,11 @@ impl Download { let mut downloaded = 0; let mut bar = if show_progress { let pb = ProgressBar::new(size); - pb.set_style(self.progress_style.clone()); + pb.set_style( + ProgressStyle::default_bar() + .template(&self.progress_template).unwrap() + .progress_chars(&self.progress_chars) + ); Some(pb) } else {