walker_common/progress/
indicatif.rs

1use indicatif::{MultiProgress, ProgressStyle};
2
3impl super::Progress for MultiProgress {
4    type Instance = indicatif::ProgressBar;
5
6    fn start(&self, work: usize) -> Self::Instance {
7        let work = work.try_into().unwrap_or(u64::MAX);
8        let bar = indicatif::ProgressBar::new(work);
9        bar.set_style(
10            ProgressStyle::default_bar()
11                .template("{msg:<20} {wide_bar} {pos}/{len} ({eta})")
12                .expect("template must parse"),
13        );
14
15        self.add(bar)
16    }
17}
18
19impl super::ProgressBar for indicatif::ProgressBar {
20    async fn increment(&mut self, work: usize) {
21        indicatif::ProgressBar::inc(self, work as u64)
22    }
23
24    async fn finish(self) {
25        indicatif::ProgressBar::finish_and_clear(&self)
26    }
27
28    async fn set_message(&mut self, msg: String) {
29        indicatif::ProgressBar::set_message(self, msg)
30    }
31}