Struct kdam::BarBuilder
source · pub struct BarBuilder { /* private fields */ }
Expand description
Implementations§
source§impl BarBuilder
impl BarBuilder
sourcepub fn total(self, total: usize) -> Self
pub fn total(self, total: usize) -> Self
The number of expected iterations.
If unspecified
, iterable.size_hint().0
is used if possible.
If 0
, only basic progress statistics are displayed (no ETA, no progressbar).
(default: 0
)
sourcepub fn leave(self, leave: bool) -> Self
pub fn leave(self, leave: bool) -> Self
If true
, keeps all traces of the progress bar upon termination.
If false
, will leave only if position is 0
.
(default: true
)
sourcepub fn ncols(self, ncols: u16) -> Self
pub fn ncols(self, ncols: u16) -> Self
The width of the entire output message.
If specified
, dynamically resizes the progress bar to stay within this bound.
If unspecified
, attempts to use KDAM_NCOLS
environment variable or adjust width automatically.
If 0
, will not print any meter (only stats).
The fallback is a meter width of 10
and no limit for the counter and statistics.
(default: 10
)
sourcepub fn mininterval(self, mininterval: f32) -> Self
pub fn mininterval(self, mininterval: f32) -> Self
Minimum progress display update interval (in seconds).
(default: 0.1
)
sourcepub fn miniters(self, miniters: usize) -> Self
pub fn miniters(self, miniters: usize) -> Self
Minimum progress display update interval (in iterations).
If miniters > 0
, specified number of iterations will be skipped and not displayed.
If your progress is erratic with both fast and slow iterations (network, skipping items, etc.) you should keep it default.
Tweak this and mininterval to get very efficient loops.
(default: 1
)
sourcepub fn dynamic_miniters(self, dynamic_miniters: bool) -> Self
pub fn dynamic_miniters(self, dynamic_miniters: bool) -> Self
Automatically adjusts miniters to correspond to mininterval after long display update lag.
(default: false
)
sourcepub fn disable(self, disable: bool) -> Self
pub fn disable(self, disable: bool) -> Self
Whether to disable the entire progress bar wrapper.
(default: false
)
sourcepub fn unit<T: Into<String>>(self, unit: T) -> Self
pub fn unit<T: Into<String>>(self, unit: T) -> Self
Unit that will be used to define the unit of each iteration.
(default: "it"
)
sourcepub fn unit_scale(self, unit_scale: bool) -> Self
pub fn unit_scale(self, unit_scale: bool) -> Self
If true
, the number of iterations will be reduced/scaled automatically
and a metric prefix following the International System of Units standard will be added (kilo, mega, etc.).
(default: false
)
sourcepub fn inverse_unit(self, inverse_unit: bool) -> Self
pub fn inverse_unit(self, inverse_unit: bool) -> Self
If true
, and the number of iterations per second is less than 1
then s/it
will be displayed instead of it/s
.
(default: false
)
sourcepub fn dynamic_ncols(self, dynamic_ncols: bool) -> Self
pub fn dynamic_ncols(self, dynamic_ncols: bool) -> Self
If true
, constantly alters ncols to the environment (allowing for window resizes).
(default: false
)
sourcepub fn bar_format<T: Into<String>>(self, bar_format: T) -> Self
Available on crate feature template
only.
pub fn bar_format<T: Into<String>>(self, bar_format: T) -> Self
template
only.Specify a custom progress bar format (may impact performance).
(default: None
)
Default Style
{desc}{percentage:3.0}%|{animation}| {count}/{total} [{elapsed}<{remaining}, {rate:.2}{unit}/s{postfix}]
Placeholders
Placeholder | Attributes | Formatting |
---|---|---|
desc | name: suffix | ✔ |
description: attaches suffix to desc if desc == “” | ||
type: string | ||
default: “: “ | ||
percentage | ✔ (true) | |
count | ✔ | |
total | ✔ | |
elapsed | name: human | ✔ |
description: alternative way to display time. | ||
type: bool | ||
default: false | ||
remaining | name: human | ✔ |
description: alternative way to display time. | ||
type: bool | ||
default: false | ||
rate | ✔ (true) | |
unit | ✔ (true) | |
postfix | ✔ (true) | |
spinner | ❌ | |
animation | ❌ |
sourcepub fn position(self, position: u16) -> Self
pub fn position(self, position: u16) -> Self
Specify the line offset to print this progress bar (starting from 0
).
Useful for managing multiple progress bars at once (eg. from threads).
(default: 0
)
Platform-specific notes
On windows, term::init method should be called first.
sourcepub fn postfix<T: Into<String>>(self, postfix: T) -> Self
pub fn postfix<T: Into<String>>(self, postfix: T) -> Self
Specify additional stats to display at the end of the progress bar.
(default: ""
)
sourcepub fn unit_divisor(self, unit_divisor: usize) -> Self
pub fn unit_divisor(self, unit_divisor: usize) -> Self
Divide values by this unit_divisor.
It is ignored unless unit_scale is true.
(default: 1000
)
sourcepub fn colour<T: Into<Colour>>(self, colour: T) -> Self
pub fn colour<T: Into<Colour>>(self, colour: T) -> Self
Progress bar colour (e.g. “green”, “#00ff00”).
(default: None
)
sourcepub fn delay<T: Into<f32>>(self, delay: T) -> Self
pub fn delay<T: Into<f32>>(self, delay: T) -> Self
Don’t display progress bar until few seconds have elapsed.
(default: 0
)
sourcepub fn animation<T: Into<Animation>>(self, animation: T) -> Self
pub fn animation<T: Into<Animation>>(self, animation: T) -> Self
Animation style to display progress bar. (default: Animation::Tqdm)
sourcepub fn spinner(self, spinner: Spinner) -> Self
Available on crate feature spinner
only.
pub fn spinner(self, spinner: Spinner) -> Self
spinner
only.Spinner to use with progress bar.
Spinner is only used when bar_format is used.
(default: None
)
sourcepub fn writer(self, writer: Writer) -> Self
pub fn writer(self, writer: Writer) -> Self
Select writer between stdout
and stderr
to display progress bar output.
(default: Writer::Stderr)
sourcepub fn force_refresh(self, force_refresh: bool) -> Self
pub fn force_refresh(self, force_refresh: bool) -> Self
If true
, each progress bar update method call will be displayed.
(default: false
)