Struct ProgressBuilder

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

A builder to create Progress with custom configuration.

See custom configuration for an example.

Implementations§

Source§

impl ProgressBuilder

Source

pub fn build(self) -> Result<Progress, Error>

Creates Progress using configuration of this ProgressBuilder.

See custom configuration for an example.

Source

pub fn new(items: Vec<Item>) -> Self

Creates ProgressBuilder to configure Progress.

If items is empty then default items are used instead.

progress_builder! macro should be used instead of this, which is same as ProgressBuilder::new(items!(ITEMS)).

Source

pub fn pre_inc(self) -> Self

Sets increment mode to PreInc.

Increment mode can be PostInc (default) or PreInc.

  • PostInc means that progress position is incremented after the associated work.
    • For example incrementing position from 2 to 3 means that work of step 3 has been completed and work of step 4 is about to begin.
  • PreInc means that progress position is incremented before the associated work.
    • For example incrementing position from 2 to 3 means that work of step 2 has been completed and work of step 3 is about to begin.
§Examples

Here first step has been completed and second is about to begin so completion percentage is 33%.

use ml_progress::progress_builder;

let progress = progress_builder!("[" percent "] " pos "/" total)
    .total(Some(3))
    .pre_inc()
    .build()?;
progress.inc(1);
progress.inc(1);
progress.finish_at_current_pos();
[ 33%] 2/3
Source

pub fn thousands_separator(self, separator: &str) -> Self

Sets thousands separator, default is space.

See custom configuration for an example.

Source

pub fn total<T: TryInto<u64>>(self, total: Option<T>) -> Self

Sets progress total, default is None.

See custom configuration for an example.

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, 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.