Skip to main content

GradientProgressBar

Struct GradientProgressBar 

Source
pub struct GradientProgressBar { /* private fields */ }
Expand description

A self-contained wrapper around indicatif::ProgressBar.

The underlying ProgressBar is Clone / Send / Sync, so an GradientProgressBar is too : share it across worker threads, pass it by reference, or keep several live at once.

Implementations§

Source§

impl GradientProgressBar

Source

pub fn new( len: u64, msg: impl Into<String>, style: BarStyle, gradient: Option<Gradient>, unit: Option<String>, ) -> Self

Create a bar with a known total, an explicit layout, an explicit style (gradient or not) and a unit (chunks, seconds, meters…)

Source

pub fn new_with_bar_width( len: u64, msg: impl Into<String>, style: BarStyle, gradient: Option<Gradient>, bar_width: usize, unit: Option<String>, ) -> Self

Create a bar with a known total, an explicit layout, an explicit style (gradient or not), a unit (chunks, seconds, meters…) and a bar width.

Source

pub fn with_total_bytes(total: u64, msg: impl Into<String>) -> Self

Create a byte-based bar (the usual entry point) with the default gradient (DEFAULT_GRADIENT).

Source

pub fn with_total_steps(total: u64, msg: impl Into<String>) -> Self

Create a step/chunk based bar with the default gradient.

Source

pub fn new_spinner(msg: impl Into<String>) -> Self

Create an indeterminate (unknown total) bar animated with a spinner.

Source

pub fn with_gradient( total: u64, msg: impl Into<String>, gradient: Gradient, ) -> Self

Create a byte-based bar with a specific Gradient.

Source

pub fn with_wide_bar(total: u64, msg: impl Into<String>) -> Self

Create a byte-based bar keeping the classic two-tone wide_bar (no true-color gradient).

Source

pub fn update(&self, position: u64)

Update the progress to an absolute position.

Source

pub fn inc(&self, delta: u64)

Advance the progress by delta.

Source

pub fn set_length(&self, len: u64)

Set a new total length.

Source

pub fn inc_length(&self, delta: u64)

Grow the total length by delta.

Source

pub fn set_message(&self, msg: impl Into<String>)

Change the message shown next to the bar.

Source

pub fn tick(&self)

Advance an indeterminate bar by one “tick” (re-draws the spinner).

Source

pub fn finish(&self)

Mark the bar as finished without clearing it.

Source

pub fn finish_with_message(&self, msg: impl Into<String>)

Mark the bar as finished, attaching a final summary message.

Source

pub fn finish_and_clear(&self)

Finish and remove the bar from the terminal entirely (pristine output).

Source

pub fn set_style(&mut self, style: BarStyle)

Swap the look & feel of an already-created bar.

Source

pub fn set_unit(&self, unit: impl Into<String>)

Source

pub fn set_gradient(&mut self, gradient: Option<Gradient>)

Change the gradient (or set None for the classic two-tone bar).

Source

pub fn set_bar_width(&mut self, width: usize)

Set the number of columns the gradient bar occupies.

Source

pub fn style(&self) -> BarStyle

The current layout of this bar.

Source

pub fn bar_width(&self) -> usize

The current width of this bar

Source

pub fn gradient(&self) -> Option<Gradient>

The gradient currently attached (if any).

Source

pub fn inner(&self) -> &ProgressBar

Borrow the underlying indicatif::ProgressBar for advanced use.

Trait Implementations§

Source§

impl Clone for GradientProgressBar

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GradientProgressBar

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.