pub struct ProgressBar { /* private fields */ }
Expand description
A log-friendly progress bar
Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn new(max_progress: usize) -> Self
pub fn new(max_progress: usize) -> Self
Create a new progress bar with default style
§Example
let max_progress = 100;
let bar = logbar::ProgressBar::new(max_progress);
Sourcepub fn with_style(max_progress: usize, style: Style) -> Self
pub fn with_style(max_progress: usize, style: Style) -> Self
Create a new progress bar with custom style
§Example
Create a progress bar with a width of 80 characters:
let style = logbar::Style::new().width(80);
let max_progress = 100;
let bar = logbar::ProgressBar::with_style(max_progress, style);
Sourcepub fn style(&self) -> &Style
pub fn style(&self) -> &Style
Get the style of the current progress bar
§Example
let max_progress = 100;
let bar = logbar::ProgressBar::new(max_progress);
assert_eq!(bar.style(), &logbar::Style::default())
Sourcepub fn inc(&self, i: usize)
pub fn inc(&self, i: usize)
Increment the progress
This method increments the internal progress counter, up to the maximum defined during the construction of the progress bar. It then updates the progress display.
§Example
let max_progress = 50;
let bar = logbar::ProgressBar::new(max_progress);
bar.inc(10); // Increment progress to 10 out of 50.
// The progress bar is at 20% now
bar.inc(10); // Increment progress to 20 out of 50.
// The progress bar is at 40% now
bar.inc(100); // Increment progress to 50 out of 50.
// The progress bar is at 100% now
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProgressBar
impl RefUnwindSafe for ProgressBar
impl Send for ProgressBar
impl Sync for ProgressBar
impl Unpin 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