Struct kdam::BarBuilder

source ·
pub struct BarBuilder { /* private fields */ }
Expand description

Create Bar with custom configurations.

Example

use kdam::BarBuilder;

let mut pb = BarBuilder::default().total(100).build().unwrap();

Implementations§

source§

impl BarBuilder

source

pub fn desc<T: Into<String>>(self, desc: T) -> Self

Prefix for progress bar. (default: "")

source

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)

source

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)

source

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)

source

pub fn mininterval(self, mininterval: f32) -> Self

Minimum progress display update interval (in seconds). (default: 0.1)

source

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)

source

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

Automatically adjusts miniters to correspond to mininterval after long display update lag. (default: false)

source

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

Whether to disable the entire progress bar wrapper. (default: false)

source

pub fn unit<T: Into<String>>(self, unit: T) -> Self

Unit that will be used to define the unit of each iteration. (default: "it")

source

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)

source

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)

source

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

If true, constantly alters ncols to the environment (allowing for window resizes). (default: false)

source

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

The initial counter value. (default: 0)

source

pub fn bar_format<T: Into<String>>(self, bar_format: T) -> Self

Available on crate feature 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
PlaceholderAttributesFormatting
descname: suffix
description: attaches suffix to desc if desc == “”
type: string
default: “: “
percentage✔ (true)
count
total
elapsedname: human
description: alternative way to display time.
type: bool
default: false
remainingname: human
description: alternative way to display time.
type: bool
default: false
rate✔ (true)
unit✔ (true)
postfix✔ (true)
spinner
animation
source

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.

source

pub fn postfix<T: Into<String>>(self, postfix: T) -> Self

Specify additional stats to display at the end of the progress bar. (default: "")

source

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)

source

pub fn colour<T: Into<Colour>>(self, colour: T) -> Self

Progress bar colour (e.g. “green”, “#00ff00”). (default: None)

source

pub fn delay<T: Into<f32>>(self, delay: T) -> Self

Don’t display progress bar until few seconds have elapsed. (default: 0)

source

pub fn animation<T: Into<Animation>>(self, animation: T) -> Self

Animation style to display progress bar. (default: Animation::Tqdm)

source

pub fn spinner(self, spinner: Spinner) -> Self

Available on crate feature spinner only.

Spinner to use with progress bar. Spinner is only used when bar_format is used. (default: None)

source

pub fn writer(self, writer: Writer) -> Self

Select writer between stdout and stderr to display progress bar output. (default: Writer::Stderr)

source

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

If true, each progress bar update method call will be displayed. (default: false)

source

pub fn build(self) -> Result<Bar, String>

Build a new Bar with custom configurations.

Note

This method only returns error when bar_format is used incorrectly.

Trait Implementations§

source§

impl Default for BarBuilder

source§

fn default() -> BarBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> Ungil for Twhere T: Send,