Struct ml_progress::ProgressBuilder
source · [−]pub struct ProgressBuilder { /* private fields */ }
Expand description
A builder to create Progress
with custom configuration.
See custom configuration for an example.
Implementations
sourceimpl ProgressBuilder
impl ProgressBuilder
sourcepub fn build(self) -> Result<Progress, Error>
pub fn build(self) -> Result<Progress, Error>
Creates Progress
using configuration of this ProgressBuilder
.
See custom configuration for an example.
sourcepub fn new(items: Vec<Item>) -> Self
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))
.
sourcepub fn pre_inc(self) -> Self
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
sourcepub fn thousands_separator(self, separator: &str) -> Self
pub fn thousands_separator(self, separator: &str) -> Self
Sets thousands separator, default is space.
See custom configuration for an example.
Auto Trait Implementations
impl !RefUnwindSafe for ProgressBuilder
impl Send for ProgressBuilder
impl Sync for ProgressBuilder
impl Unpin for ProgressBuilder
impl !UnwindSafe for ProgressBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more