Struct zzz::ProgressBar
source · [−]pub struct ProgressBar { /* private fields */ }Expand description
Progress bar to be rendered on the terminal.
Example
use zzz::prelude::*;
let mut bar = ProgressBar::with_target(123);
for _ in 0..123 {
bar.add(1);
}Implementations
sourceimpl ProgressBar
impl ProgressBar
Constructors.
sourcepub fn smart() -> Self
pub fn smart() -> Self
Creates a smart progress bar, attempting to infer the target from size hints.
sourcepub fn with_target(target: usize) -> Self
pub fn with_target(target: usize) -> Self
Creates a progress bar with an explicit target value.
sourceimpl ProgressBar
impl ProgressBar
Builder-style methods.
sourcepub fn config(self, cfg: &'static ProgressBarConfig) -> Self
pub fn config(self, cfg: &'static ProgressBarConfig) -> Self
Replace the config of the progress bar.
sourcepub fn force_spinner(self) -> Self
pub fn force_spinner(self) -> Self
Force display as a spinner even if size hints are present.
sourceimpl ProgressBar
impl ProgressBar
Value manipulation and access.
pub fn process_size_hint(&mut self, hint: (usize, Option<usize>))
sourcepub fn set(&mut self, n: usize)
pub fn set(&mut self, n: usize)
Set the progress bar value to a new, absolute value.
This doesn’t automatically redraw the progress-bar.
See set_sync for a thread-safe version.
sourcepub fn add(&mut self, n: usize) -> usize
pub fn add(&mut self, n: usize) -> usize
Add n to the value of the progress bar.
See add_sync for a thread-safe version.
sourcepub fn update_ctr(&self) -> usize
pub fn update_ctr(&self) -> usize
How often has the value been changed since creation?
sourcepub fn set_message(&mut self, text: Option<impl Into<String>>)
pub fn set_message(&mut self, text: Option<impl Into<String>>)
Set the current task description text.
sourcepub fn set_message_sync(&self, text: Option<impl Into<String>>)
pub fn set_message_sync(&self, text: Option<impl Into<String>>)
Synchronized version for set_message.
sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Calculate the elapsed time since creation of the progress bar.
sourcepub fn iters_per_sec(&self) -> f32
pub fn iters_per_sec(&self) -> f32
Calculate the mean iterations per second since creation of the progress bar.
sourcepub fn updates_per_sec(&self) -> f32
pub fn updates_per_sec(&self) -> f32
Calculate the mean progress bar updates per second since creation of the progress bar.
sourcepub fn timer_progress(&self, timer: Duration) -> f32
pub fn timer_progress(&self, timer: Duration) -> f32
Calculates the progress of a rolling timer.
Returned values are always between 0 and 1. Timers are calculated from the start of the progress bar.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for ProgressBar
impl Send for ProgressBar
impl Sync for ProgressBar
impl Unpin for ProgressBar
impl !UnwindSafe for ProgressBar
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more