Skip to main content

ProgressBarBuilder

Struct ProgressBarBuilder 

Source
pub struct ProgressBarBuilder { /* private fields */ }
Available on crate feature print only.
Expand description

Builder for a progress bar

Implementations§

Source§

impl ProgressBarBuilder

Source

pub fn new(message: String) -> Self

Start building a progress bar. Note cu::progress is the canonical shorthand

Source

pub fn total(self, total: usize) -> Self

Set the total steps. 0 means total is unknown, which can be set at a later point.

By default, the progress bar is “unbounded”, meaning there is no individual steps

cu::progress("doing something").total(10);
Source

pub fn total_bytes(self, total: u64) -> Self

Set the total bytes and set the progress to be displayed using byte units (SI). 0 means total is unknown, which can be set at a later point.

cu::progress("doing something").total_bytes(1000000);
Source

pub fn keep(self, keep: bool) -> Self

Set if the progress bar should be kept in the output after it’s done.

Default is true for root progress bars and false for child progress bars

cu::progress("doing something").keep(false);
Source

pub fn eta(self, show: bool) -> Self

Set if ETA (estimated time) should be displayed. Only effective if total is not zero (i.e. not unbounded). Default is true

cu::progress("doing something").total(10).eta(false);
Source

pub fn percentage(self, show: bool) -> Self

Set if percentage should be displayed. Only effective if total is not zero (i.e. not unbounded). Default is true

cu::progress("doing something").total(10).percentage(false);
Source

pub fn when_done(self, message: impl Into<String>) -> Self

Set a message to be displayed when the progress is done. Requires keep(true) - which is the default, but when_done will not automatically turn it on for you.

Default is the message of the progress bar followed by done.

cu::progress("doing something").when_done("something is done!");
Source

pub fn when_interrupt(self, message: impl Into<String>) -> Self

Set a message to be displayed when the progress is interrupted.

Default is the message of the progress bar followed by interrupted.

cu::progress("doing something").when_interrupt("something is interrupted!");
Source

pub fn max_display_children(self, num: usize) -> Self

Set the max number of children to display at a time. Default is unbounded.

cu::progress("doing something").max_display_children(30);
Source

pub fn parent(self, parent: Option<Arc<ProgressBar>>) -> Self

Set the parent progress bar.

If the parent is known to be Some, use parent.child(...) instead

Source

pub fn spawn(self) -> Arc<ProgressBar> ⓘ

Build and start displaying the bar in the console

Trait Implementations§

Source§

impl Clone for ProgressBarBuilder

Source§

fn clone(&self) -> ProgressBarBuilder

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 ProgressBarBuilder

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, <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.