PROGRESS_BAR

Struct PROGRESS_BAR 

Source
pub struct PROGRESS_BAR { /* private fields */ }

Methods from Deref<Target = ProgressBar>§

Source

pub fn set_style(&self, style: ProgressStyle)

Overrides the stored style.

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

Source

pub fn enable_steady_tick(&self, ms: u64)

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.

Source

pub fn disable_steady_tick(&self)

Undoes enable_steady_tick.

Source

pub fn set_draw_delta(&self, n: u64)

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
Source

pub fn tick(&self)

Manually ticks the spinner or progress bar.

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

Source

pub fn inc(&self, delta: u64)

Advances the position of a progress bar by delta.

Source

pub fn is_hidden(&self) -> bool

A quick convenience check if the progress bar is hidden.

Source

pub fn println<I>(&self, msg: I)
where I: Into<String>,

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.

Source

pub fn set_position(&self, pos: u64)

Sets the position of the progress bar.

Source

pub fn set_length(&self, len: u64)

Sets the length of the progress bar.

Source

pub fn set_prefix(&self, prefix: &str)

Sets the current prefix of the progress bar.

Source

pub fn set_message(&self, msg: &str)

Sets the current message of the progress bar.

Source

pub fn reset_eta(&self)

Resets the ETA calculation.

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

Source

pub fn finish(&self)

Finishes the progress bar and leaves the current message.

Source

pub fn finish_with_message(&self, msg: &str)

Finishes the progress bar and sets a message.

Source

pub fn finish_and_clear(&self)

Finishes the progress bar and completely clears it.

Source

pub fn set_draw_target(&self, target: ProgressDrawTarget)

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

pub fn wrap_iter<It>(&self, it: It) -> ProgressBarIter<It>
where It: Iterator,

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

pub fn wrap_read<R>(&self, read: R) -> ProgressBarRead<R>
where R: Read,

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§

Source§

impl Deref for PROGRESS_BAR

Source§

type Target = ProgressBar

The resulting type after dereferencing.
Source§

fn deref(&self) -> &ProgressBar

Dereferences the value.
Source§

impl LazyStatic for PROGRESS_BAR

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.