[][src]Crate yapb

Yet Another Progress Bar

This library provides lightweight tools for rendering progress indicators and related information. 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 = Bar::new();
  print!("{}", termion::cursor::Save);
  for i in 0..100 {
    bar.set(i as f32 / 100.0);
    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));
  }
}

Modules

prefix

Helpers to display compact human-readable numbers

Structs

Bar

An unusually high-resolution progress bar using Unicode block elements

Counter16

A spinner that cycles through 16 states by counting in binary using block elements

Counter256

A spinner that cycles through 256 states by counting in binary using braille

MovingAverage

Exponential moving average, useful for computing throughput

Snake

A spinner that cycles through many states with a snake made of 1-6 braille dots

Spinner4

A spinner that cycles through 4 states with a single spinning block element

Spinner8

A spinner that cycles through 8 states with a single spinning braille dot

Traits

Progress

Indicators that communicate a proportion of progress towards a known end point

Spinner

Indicators that animate through some number of states to indicate activity with indefinite duration