Debian Codegraph @

debian/rust-vendor/indicatif/examples/download-continued.rs

raw
1 use std::cmp::min;
2 use std::thread;
3 use std::time::Duration;
4
5 use indicatif::{ProgressBar, ProgressStyle};
6
7 fn main() {
8 let mut downloaded = 69369369;
9 let total_size = 231231231;
10
11 let pb = ProgressBar::new(total_size);
12 pb.set_style(
13 ProgressStyle::with_template(
14 "{spinner:.green} [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})",
15 )
16 .unwrap()
17 .progress_chars("#>-"),
18 );
19 pb.set_position(downloaded);
20 pb.reset_eta();
21
22 while downloaded < total_size {
23 downloaded = min(downloaded + 123211, total_size);
24 pb.set_position(downloaded);
25 thread::sleep(Duration::from_millis(12));
26 }
27
28 pb.finish_with_message("downloaded");
29 }