writer/
writer.rs

1extern crate progress_streams;
2
3use progress_streams::ProgressWriter;
4use std::io::{Write, sink};
5
6fn main() {
7    let mut total = 0;
8    let mut file = sink();
9    let mut writer = ProgressWriter::new(&mut file, |progress: usize| {
10        total += progress;
11        println!("Written {} Kib", total / 1024);
12    });
13
14
15    let buffer = [0u8; 8192];
16    for _ in 0..100_000 {
17        writer.write(&buffer).unwrap();
18    }
19}