[][src]Struct progress_bar::progress_bar::ProgressBar

pub struct ProgressBar { /* fields omitted */ }

Methods

impl ProgressBar[src]

pub fn new(max: usize) -> Self[src]

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();

pub fn set_width(&mut self, w: usize)[src]

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

pub fn set_progression(&mut self, p: usize)[src]

Set the progression

pub fn inc(&mut self)[src]

Increment the progression by 1

pub fn set_action(&mut self, a: &str, c: Color, s: Style)[src]

Set the global action displayed before the progress bar.

pub fn print_final_info(
    &mut self,
    info_name: &str,
    text: &str,
    info_color: Color,
    info_style: Style
)
[src]

Log something, without display update

pub fn print_info(
    &mut self,
    info_name: &str,
    text: &str,
    info_color: Color,
    info_style: Style
)
[src]

Log something

pub fn display(&self)[src]

Display the bar

pub fn finalize(&mut self)[src]

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

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.