pub struct ProgressBar { /* private fields */ }Expand description
A progress bar for displaying operation progress.
§Example
use click::termui::ProgressBar;
let mut bar = ProgressBar::new(100, Some("Processing"), true, true, true, 40);
for i in 0..100 {
// Do work...
bar.update(1);
}
bar.finish();
// Custom fill/empty characters
let mut bar = ProgressBar::new(100, None, true, true, false, 30)
.fill_char('█')
.empty_char('░');Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn new(
length: usize,
label: Option<&str>,
show_eta: bool,
show_percent: bool,
show_pos: bool,
width: usize,
) -> Self
pub fn new( length: usize, label: Option<&str>, show_eta: bool, show_percent: bool, show_pos: bool, width: usize, ) -> Self
Create a new progress bar.
§Arguments
length- Total number of items to processlabel- Optional label to display before the barshow_eta- Whether to show estimated time remainingshow_percent- Whether to show percentage completeshow_pos- Whether to show position/lengthwidth- Width of the bar portion in characters
Sourcepub fn fill_char(self, c: char) -> Self
pub fn fill_char(self, c: char) -> Self
Set the character used for the filled portion of the bar.
Default is ‘#’.
§Example
use click::termui::ProgressBar;
let bar = ProgressBar::new(100, None, true, true, false, 30)
.fill_char('█');Sourcepub fn empty_char(self, c: char) -> Self
pub fn empty_char(self, c: char) -> Self
Set the character used for the empty portion of the bar.
Default is ‘-’.
§Example
use click::termui::ProgressBar;
let bar = ProgressBar::new(100, None, true, true, false, 30)
.empty_char('░');Sourcepub fn update(&mut self, n: usize)
pub fn update(&mut self, n: usize)
Update the progress bar by advancing by n items.
§Arguments
n- Number of items completed since last update
Sourcepub fn set_position(&mut self, pos: usize)
pub fn set_position(&mut self, pos: usize)
Trait Implementations§
Source§impl Drop for ProgressBar
impl Drop for ProgressBar
Auto Trait Implementations§
impl Freeze for ProgressBar
impl RefUnwindSafe for ProgressBar
impl Send for ProgressBar
impl Sync for ProgressBar
impl Unpin for ProgressBar
impl UnsafeUnpin for ProgressBar
impl UnwindSafe for ProgressBar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more