Struct indicatif::ProgressBar [−][src]
pub struct ProgressBar { /* fields omitted */ }
Expand description
A progress bar or spinner.
The progress bar is an Arc
around an internal state. When the progress
bar is cloned it just increments the refcount which means the bar is
shared with the original one.
Implementations
impl ProgressBar
[src]
impl ProgressBar
[src]pub fn new(len: u64) -> ProgressBar
[src]
pub fn new(len: u64) -> ProgressBar
[src]Creates a new progress bar with a given length.
This progress bar by default draws directly to stderr, and refreshes a maximum of 15 times a second. To change the refresh rate set the draw target to one with a different refresh rate.
pub fn hidden() -> ProgressBar
[src]
pub fn hidden() -> ProgressBar
[src]Creates a completely hidden progress bar.
This progress bar still responds to API changes but it does not have a length or render in any way.
pub fn with_draw_target(len: u64, target: ProgressDrawTarget) -> ProgressBar
[src]
pub fn with_draw_target(len: u64, target: ProgressDrawTarget) -> ProgressBar
[src]Creates a new progress bar with a given length and draw target.
pub fn with_style(self, style: ProgressStyle) -> ProgressBar
[src]
pub fn with_style(self, style: ProgressStyle) -> ProgressBar
[src]A convenience builder-like function for a progress bar with a given style.
pub fn new_spinner() -> ProgressBar
[src]
pub fn new_spinner() -> ProgressBar
[src]Creates a new spinner.
This spinner by default draws directly to stderr. This adds the default spinner style to it.
pub fn set_style(&self, style: ProgressStyle)
[src]
pub fn set_style(&self, style: ProgressStyle)
[src]Overrides the stored style.
This does not redraw the bar. Call tick
to force it.
pub fn enable_steady_tick(&self, ms: u64)
[src]
pub fn enable_steady_tick(&self, ms: u64)
[src]Spawns a background thread to tick the progress bar.
When this is enabled a background thread will regularly tick the progress back in the given interval (milliseconds). This is useful to advance progress bars that are very slow by themselves.
When steady ticks are enabled calling .tick()
on a progress
bar does not do anything.
pub fn disable_steady_tick(&self)
[src]
pub fn disable_steady_tick(&self)
[src]Undoes enable_steady_tick
.
pub fn set_draw_delta(&self, n: u64)
[src]
pub fn set_draw_delta(&self, n: u64)
[src]Limit redrawing of progress bar to every n
steps. Defaults to 0.
By default, the progress bar will redraw whenever its state advances. This setting is helpful in situations where the overhead of redrawing the progress bar dominates the computation whose progress is being reported.
If n
is greater than 0, operations that change the progress bar such
as .tick()
, .set_message()
and .set_length()
will no longer cause
the progress bar to be redrawn, and will only be shown once the
position advances by n
steps.
let n = 1_000_000; let pb = ProgressBar::new(n); pb.set_draw_delta(n / 100); // redraw every 1% of additional progress
Note that ProgressDrawTarget
may impose additional buffering of redraws.
pub fn tick(&self)
[src]
pub fn tick(&self)
[src]Manually ticks the spinner or progress bar.
This automatically happens on any other change to a progress bar.
pub fn is_finished(&self) -> bool
[src]
pub fn println<I: Into<String>>(&self, msg: I)
[src]
pub fn println<I: Into<String>>(&self, msg: I)
[src]Print a log line above the progress bar.
If the progress bar was added to a MultiProgress
, the log line will be
printed above all other progress bars.
Note that if the progress bar is hidden (which by default happens if the progress bar is redirected into a file) println will not do anything either.
pub fn set_position(&self, pos: u64)
[src]
pub fn set_position(&self, pos: u64)
[src]Sets the position of the progress bar.
pub fn set_length(&self, len: u64)
[src]
pub fn set_length(&self, len: u64)
[src]Sets the length of the progress bar.
pub fn inc_length(&self, delta: u64)
[src]
pub fn inc_length(&self, delta: u64)
[src]Increase the length of the progress bar.
pub fn set_prefix(&self, prefix: &str)
[src]
pub fn set_prefix(&self, prefix: &str)
[src]Sets the current prefix of the progress bar.
For the prefix to be visible, {prefix}
placeholder
must be present in the template (see ProgressStyle
).
pub fn set_message(&self, msg: &str)
[src]
pub fn set_message(&self, msg: &str)
[src]Sets the current message of the progress bar.
For the message to be visible, {msg}
placeholder
must be present in the template (see ProgressStyle
).
pub fn reset_eta(&self)
[src]
pub fn reset_eta(&self)
[src]Resets the ETA calculation.
This can be useful if progress bars make a huge jump or were paused for a prolonged time.
pub fn reset_elapsed(&self)
[src]
pub fn reset_elapsed(&self)
[src]Resets elapsed time
pub fn reset(&self)
[src]
pub fn finish_at_current_pos(&self)
[src]
pub fn finish_at_current_pos(&self)
[src]Finishes the progress bar at current position and leaves the current message.
pub fn finish_with_message(&self, msg: &str)
[src]
pub fn finish_with_message(&self, msg: &str)
[src]Finishes the progress bar and sets a message.
For the message to be visible, {msg}
placeholder
must be present in the template (see ProgressStyle
).
pub fn finish_and_clear(&self)
[src]
pub fn finish_and_clear(&self)
[src]Finishes the progress bar and completely clears it.
pub fn abandon_with_message(&self, msg: &str)
[src]
pub fn abandon_with_message(&self, msg: &str)
[src]Finishes the progress bar and sets a message, and leaves the current progress.
For the message to be visible, {msg}
placeholder
must be present in the template (see ProgressStyle
).
pub fn set_draw_target(&self, target: ProgressDrawTarget)
[src]
pub fn set_draw_target(&self, target: ProgressDrawTarget)
[src]Sets a different draw target for the progress bar.
This can be used to draw the progress bar to stderr for instance:
let pb = ProgressBar::new(100); pb.set_draw_target(ProgressDrawTarget::stderr());
pub fn wrap_iter<It: Iterator>(&self, it: It) -> ProgressBarIter<It>
[src]
pub fn wrap_iter<It: Iterator>(&self, it: It) -> ProgressBarIter<It>
[src]Wraps an iterator with the progress bar.
let v = vec![1, 2, 3]; let pb = ProgressBar::new(3); for item in pb.wrap_iter(v.iter()) { // ... }
pub fn wrap_read<R: Read>(&self, read: R) -> ProgressBarWrap<R>ⓘNotable traits for ProgressBarWrap<R>
impl<R: Read> Read for ProgressBarWrap<R>impl<W: Write> Write for ProgressBarWrap<W>
[src]
pub fn wrap_read<R: Read>(&self, read: R) -> ProgressBarWrap<R>ⓘNotable traits for ProgressBarWrap<R>
impl<R: Read> Read for ProgressBarWrap<R>impl<W: Write> Write for ProgressBarWrap<W>
[src]Wraps a Reader with the progress bar.
let source = File::open("work.txt")?; let mut target = File::create("done.txt")?; let pb = ProgressBar::new(source.metadata()?.len()); io::copy(&mut pb.wrap_read(source), &mut target);
pub fn wrap_write<W: Write>(&self, write: W) -> ProgressBarWrap<W>ⓘNotable traits for ProgressBarWrap<R>
impl<R: Read> Read for ProgressBarWrap<R>impl<W: Write> Write for ProgressBarWrap<W>
[src]
pub fn wrap_write<W: Write>(&self, write: W) -> ProgressBarWrap<W>ⓘNotable traits for ProgressBarWrap<R>
impl<R: Read> Read for ProgressBarWrap<R>impl<W: Write> Write for ProgressBarWrap<W>
[src]Wraps a Writer with the progress bar.
let mut source = File::open("work.txt")?; let target = File::create("done.txt")?; let pb = ProgressBar::new(source.metadata()?.len()); io::copy(&mut source, &mut pb.wrap_write(target));
pub fn position(&self) -> u64
[src]
Trait Implementations
impl Clone for ProgressBar
[src]
impl Clone for ProgressBar
[src]fn clone(&self) -> ProgressBar
[src]
fn clone(&self) -> ProgressBar
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
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
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more