pub struct ProgressBar { /* private fields */ }Expand description
A progress bar that tracks completion of a task.
§Example
use pulsebar::ProgressBar;
let bar = ProgressBar::new(100).with_message("Downloading");
for _ in 0..100 {
bar.advance(1);
}
bar.finish_success("Download complete");§Custom Format
use pulsebar::ProgressBar;
let bar = ProgressBar::new(1000)
.with_message("Sync")
.with_format("{msg} [{bar:30}] {pos}/{total} {rate}/s ETA {eta}");Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn with_message(self, message: &str) -> Self
pub fn with_message(self, message: &str) -> Self
Set the display message. Consumes and returns self for chaining.
Sourcepub fn with_style(self, style: Style) -> Self
pub fn with_style(self, style: Style) -> Self
Set the visual style. Consumes and returns self for chaining.
Sourcepub fn with_theme(self, theme: Theme) -> Self
pub fn with_theme(self, theme: Theme) -> Self
Set the color theme. Consumes and returns self for chaining.
Sourcepub fn with_format(self, format: &str) -> Self
pub fn with_format(self, format: &str) -> Self
Set a custom format string. Consumes and returns self for chaining.
Supported placeholders: {msg}, {bar}, {bar:N}, {pos}, {total},
{pct}, {elapsed}, {rate}, {eta}.
Sourcepub fn set_message(&self, message: &str)
pub fn set_message(&self, message: &str)
Update the display message.
Sourcepub fn set_position(&self, pos: u64)
pub fn set_position(&self, pos: u64)
Set the position to an absolute value (clamped to total).
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if the bar is finished.
Sourcepub fn eta(&self) -> Option<f64>
pub fn eta(&self) -> Option<f64>
Get the estimated time remaining in seconds, or None if unavailable.
Sourcepub fn finish_success(&self, message: &str)
pub fn finish_success(&self, message: &str)
Mark the bar as successfully completed with a message.
Sourcepub fn finish_error(&self, message: &str)
pub fn finish_error(&self, message: &str)
Mark the bar as failed with an error message.
Trait Implementations§
Source§impl Clone for ProgressBar
impl Clone for ProgressBar
Source§fn clone(&self) -> ProgressBar
fn clone(&self) -> ProgressBar
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto 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