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§

source§

impl ProgressBar

Constructors.

source

pub fn smart() -> Self

Creates a smart progress bar, attempting to infer the target from size hints.

source

pub fn spinner() -> Self

Creates a spinner, a progress bar with indeterminate target value.

source

pub fn with_target(target: usize) -> Self

Creates a progress bar with an explicit target value.

source§

impl ProgressBar

Builder-style methods.

source

pub fn config(self, cfg: &'static ProgressBarConfig) -> Self

Replace the config of the progress bar.

source

pub fn force_spinner(self) -> Self

Force display as a spinner even if size hints are present.

source

pub fn unit(self, unit: Unit) -> Self

Set the unit to be used when formatting values.

source§

impl ProgressBar

Value manipulation and access.

source

pub fn process_size_hint(&mut self, hint: (usize, Option<usize>))

source

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.

source

pub fn set_sync(&self, n: usize)

Synchronized version fo set.

source

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.

source

pub fn add_sync(&self, n: usize) -> usize

Synchronized version fo add.

source

pub fn update_ctr(&self) -> usize

How often has the value been changed since creation?

source

pub fn value(&self) -> usize

Get the current value of the progress bar.

source

pub fn message(&self) -> Option<String>

Get the current task description text.

source

pub fn set_message(&mut self, text: Option<impl Into<String>>)

Set the current task description text.

source

pub fn set_message_sync(&self, text: Option<impl Into<String>>)

Synchronized version for set_message.

source

pub fn progress(&self) -> Option<f32>

Calculate the current progress, 0.0 .. 1.0.

source

pub fn elapsed(&self) -> Duration

Calculate the elapsed time since creation of the progress bar.

source

pub fn eta(&self) -> Option<Duration>

Estimate the duration until completion.

source

pub fn iters_per_sec(&self) -> f32

Calculate the mean iterations per second since creation of the progress bar.

source

pub fn updates_per_sec(&self) -> f32

Calculate the mean progress bar updates per second since creation of the progress bar.

source

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.

source

pub fn redraw(&self)

Forces a redraw of the progress bar.

Trait Implementations§

source§

impl Drop for ProgressBar

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.