Struct indicatif::ProgressBar

source ·
pub struct ProgressBar { /* private fields */ }
Expand description

A progress bar or spinner.

Implementations§

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

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.

Creates a new progress bar with a given length and draw target.

Creates a new spinner.

This spinner by default draws directly to stderr This adds the default spinner style to it.

Overrides the stored style.

This does not redraw the bar. Call tick to force it.

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.

Undoes enable_steady_tick.

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

Manually ticks the spinner or progress bar.

This automatically happens on any other change to a progress bar.

Advances the position of a progress bar by delta.

Print a log line above the progress bar.

Sets the position of the progress bar.

Sets the length of the progress bar.

Sets the current prefix of the progress bar.

Sets the current message of the progress bar.

Resets the ETA calculation.

This can be useful if progress bars make a huge jump or were paused for a prolonged time.

Finishes the progress bar and leaves the current message.

Finishes the progress bar and sets a message.

Finishes the progress bar and completely clears it.

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());

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()) {
    // ...
}

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);

Trait Implementations§

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.