pub struct ProgressBar { /* private fields */ }

Implementations

Creates a progress bar with the total number of actions.
You will need to call inc method when an action is completed and the bar progression will be incremented by 1.
Don’t print things with print macro while the bar is running; use the print_info method instead.

Example
use progress_bar::progress_bar::ProgressBar;
use progress_bar::color::{Color, Style};
use std::{thread, time};
 
// if you have 81 pages to load
let mut progress_bar = ProgressBar::new(81);
progress_bar.set_action("Loading", Color::Blue, Style::Bold);

for i in 0..81 {
    // load page
    thread::sleep(time::Duration::from_millis(50));
 
    // log the result
    if i == 14 {
        progress_bar.print_info("Failed", "https://zefzef.zef", Color::Red, Style::Blink);
    } else {
        progress_bar.print_info("Success", "https://example.com", Color::Red, Style::Blink);
    }
     
    // update the progression by 1
    progress_bar.inc();
}
progress_bar.print_final_info("Loading", "Load complete", Color::LightGreen, Style::Bold);
// Or, to leave the progress bar at 100%:
// progress_bar.finalize();

Set the width of the progress bar in caracters in console (default: 50)

Set the progression

Increment the progression by 1

Set the global action displayed before the progress bar.

Log something, without display update

Log something

Display the bar

Mark the end of the progress bar - updates will make a ‘new’ bar

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.