pub struct BarBuilder { /* private fields */ }
Expand description

Helper struct for building a progress bar.

Examples
use progress_string::BarBuilder;

let bar = BarBuilder::new()
                    .total(1000000)
                    .width(20)
                    .empty_char('0')
                    .full_char('X')
                    .include_percent()
                    .build();

the above would look something like this [XXXXXXXXXX0000000000] 50.00%

Implementations

Create a new BarBuilder.

Update the total (default 100).

Examples
use progress_string::BarBuilder;

let thousand = BarBuilder::new().total(1000).build();
// yields [█                                                 ]

Update the progress section’s width (default 50).

use progress_string::BarBuilder;

let bar = BarBuilder::new().width(10);
// yields [          ]

Update the character you want to use as an empty section of the progress bar (default ’ ’).

Examples
use progress_string::BarBuilder;

let zero_emp = BarBuilder::new().empty_char('0').build();
// yields
// [██████████00000000000]

Update the character you want to use as a full section of the bar (default ‘█’).

Examples
use progress_string::BarBuilder;

let x_bar = BarBuilder::new().full_char('X').build();
// yields [XXXXXX      ]
let y_bar = BarBuilder::new().full_char('Y').build();
// yields [YYYYYY      ]

Update the character you want to use to lead the full section of the bar (defaults to the value of full_char if not provided).

Examples
use progress_string::BarBuilder;

let x_bar = BarBuilder::new()
                .full_char('X')
                .leading_char('}')
                .build();
// yields [XXXXXX}     ]
let y_bar = BarBuilder::new()
                .full_char('Y')
                .leading_char(')')
                .build();
// yields [YYYYYY)     ]

Update the bar to include the percent after the bar representation (default false).

Examples
use progress_string::BarBuilder;

let no_p = BarBuilder::new().include_percent().build();
// yields [██████████          ] 50.00%
let with_p = BarBuilder::new();
// yields [██████████          ]

Update the bar to include the divison after the bar representation.

Examples
use progress_string::BarBuilder;

let mut no_n = BarBuilder::new().build();
no_n.replace(50);
// yields [██████████          ]
let mut with_n = BarBuilder::new().include_numbers().build();
with_n.replace(50)
// yields [██████████          ] 50/100
👎Deprecated

deprecated please use build

Complete building your bar and return the updated struct.

Examples
use progress_string::BarBuilder;

let bar = BarBuilder::new().build();
// yields a default bar instance

Trait Implementations

Returns the “default value” for a type. Read more

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.