pbars

Crates.iopbars
lib.rspbars
version0.1.2
sourcesrc
created_at2022-02-04 07:49:20.544187
updated_at2022-02-04 07:59:12.15803
descriptionA crate for creating progress bars quickly and easily
homepagehttps://crates.io/crates/pbars
repositoryhttps://github.com/sk3pz/pbars
max_upload_size
id526668
size36,288
Eric Shreve (Sk3pz)

documentation

https://docs.rs/pbars/latest/pbars/index.html

README

pbars

A rust crate for progress bars in the terminal.
image

Example:

use pbars::{PBar, BarType};
use std::thread::sleep;
use std::time::Duration;

fn main() {
    // using crossterm, this will create a pbar at 0,0
    // without crossterm, this is the only way to create a bar
    let mut pbar = PBar::new(BarType::Bar, true, true, 20);

    for x in 0..1000 {
        // get the percentage complete as a decimal
        let percentage_decimal = x as f32 / 1000.0;
        // scale the percentage from 0..1 to 0..100 and convert to a u8
        let percent = (percentage_decimal * 100.0) as u8;
        // update the pbar
        pbar.update(percent);
        // draw the pbar
        pbar.draw();
        // delay for 10ms, making this run in 10 seconds
        sleep(Duration::from_millis(10));
    }
}
Commit count: 11

cargo fmt