Struct progress_string::Bar [] [src]

pub struct Bar {
    pub current_partial: usize,
    pub total: usize,
    // some fields omitted
}

Represents a progress bar, this can be used to get your progress string

Fields

Methods

impl Bar
[src]

[src]

Bar constructor with default values

impl Bar
[src]

[src]

Update the current_partial value by adding the to_add parameter

Examples

let mut bar = Bar::default();
bar.update(10);
assert_eq!(bar.current_partial, 110);

[src]

Update the cureent partial by replacing the current value

Examples

let mut bar = Bar::default();
bar.replace(10);
assert_eq!(bar.current_partial, 10);

impl Bar
[src]

[src]

Get the string representation of the progress bar This stiring will include brackets ([]) around the empty/full characters, the width is determined by the width property. If bar.include_percent == true the resulting string will include a space and the percent with 2 decimal palces followed by %.

Examples

let mut with_percent = BarBuilder::new().include_percent()
                                            .get_bar();
with_percent.update(50);
println!("{}", with_percent.to_string());
//prints [█████████████████████████                         ] 50.00%
let mut no_percent = BarBuilder::new().get_bar();
no_percent.update(50);
//prints [█████████████████████████                         ]

impl Bar
[src]

[src]

Get the current width of characters in the bar, this includes the brackets, spaces and percent if set

Examples

let bar = Bar::default();
println!("{}", bar.get_width());
//prints 52
let mut with_percent = BarBuilder;;new().include_precent();
println!("{}", bar.get_width());
//prints 58
with_percent.update(10);
println!("{}", bar.get_width());
//prints 59
with_percent.replace(100);
println!("{}", bar.get_width());
//prints 60

[src]

Similar to get_width but gets the value before the last update or replace call this is useful for when you are trying to clear the terminal