Yet Another Progress Bar
This library provides lightweight tools for rendering Unicode progress indicators. Unlike most similar libraries, it
performs no IO internally, instead providing Display implementations. Handling the details of any particular
output device is left to the user.
Examples
The termion crate can be used to implement good behavior on an ANSI terminal:
extern crate yapb;
extern crate termion;
use std::{thread, time};
use std::io::{self, Write};
use yapb::{Bar, Progress};
fn main() {
let mut bar = yapb::Bar::new();
print!("{}", termion::cursor::Save);
for i in 0..100 {
bar.set(i * (u32::max_value() / 100));
let (width, _) = termion::terminal_size().unwrap();
print!("{}{}[{:width$}]",
termion::clear::AfterCursor, termion::cursor::Restore,
bar, width = width as usize - 2);
io::stdout().flush().unwrap();
thread::sleep(time::Duration::from_millis(100));
}
}