Struct Config

Source
pub struct Config {
    pub prefix: Cow<'static, str>,
    pub total: Option<f64>,
    pub leave: bool,
    pub disable: bool,
    pub unit: Cow<'static, str>,
    pub unit_scale: f64,
    pub postfix: Cow<'static, str>,
    pub colour: Cow<'static, str>,
    pub progress_chars: Cow<'static, str>,
}
Expand description

Configuration for the Tqdm and ParTqdm progress bars.

Fields§

§prefix: Cow<'static, str>

Placed at the start of the progress bar (default = “”)

§total: Option<f64>

Expected number of iterations (default = iter.len())

§leave: bool

Whether or not to leave the progress bar behind after completion (default = true)

§disable: bool

Hides the progress bar (default = false)

§unit: Cow<'static, str>

Measurement type used for it/s (default = “it”)

§unit_scale: f64

Scales the it/s, position, and total numbers. (default = 1)

§postfix: Cow<'static, str>

Placed at the end of the progress bar (default = “”)

§colour: Cow<'static, str>

Color used for the progress bar (default = “white”)

§progress_chars: Cow<'static, str>

Characters used for displaying the progress bar.

Implementations§

Source§

impl Config

Source

pub const fn new() -> Self

Examples found in repository?
examples/multiple.rs (line 4)
3fn main() {
4    let config = Config::new().with_progress_chars(">= ");
5    std::thread::scope(|scope| {
6        for _ in 0..3 {
7            scope.spawn(|| for _ in (0..2 << 24).tqdm_config(config.clone()) {});
8        }
9    });
10}
More examples
Hide additional examples
examples/config.rs (line 5)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

pub fn with_prefix(self, prefix: impl Into<Cow<'static, str>>) -> Self

Placed at the start of the progress bar (default = “”)

Source

pub fn with_desc(self, desc: impl Into<Cow<'static, str>>) -> Self

Placed at the start of the progress bar (default = “”) Like tqdm this method adds “: “ to the end of the prefix.

Examples found in repository?
examples/config.rs (line 6)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

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

Expected number of iterations (default = iter.len())

Examples found in repository?
examples/config.rs (line 7)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

pub fn with_total_float(self, total: f64) -> Self

Expected number of iterations (default = iter.len())

Source

pub fn with_leave(self, leave: bool) -> Self

Whether or not to leave the progress bar behind after completion (default = true)

Examples found in repository?
examples/config.rs (line 9)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

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

Hides the progress bar (default = false)

Examples found in repository?
examples/config.rs (line 8)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

pub fn with_unit(self, unit: impl Into<Cow<'static, str>>) -> Config

Measurement type used for it/s (default = “it”)

Examples found in repository?
examples/config.rs (line 10)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

pub fn with_scale(self, scale: impl Into<f64>) -> Config

Scales the it/s, position, and total numbers. (default = 1)

Examples found in repository?
examples/config.rs (line 11)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

pub fn with_postfix(self, postfix: impl Into<Cow<'static, str>>) -> Config

Placed at the end of the progress bar (default = “”)

Examples found in repository?
examples/config.rs (line 12)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

pub fn with_color(self, colour: impl Into<Cow<'static, str>>) -> Config

Color used for the progress bar (default = “white”)

Examples found in repository?
examples/config.rs (line 13)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}
Source

pub fn with_progress_chars( self, progress_chars: impl Into<Cow<'static, str>>, ) -> Config

Characters used for displaying the progress bar.

Examples found in repository?
examples/multiple.rs (line 4)
3fn main() {
4    let config = Config::new().with_progress_chars(">= ");
5    std::thread::scope(|scope| {
6        for _ in 0..3 {
7            scope.spawn(|| for _ in (0..2 << 24).tqdm_config(config.clone()) {});
8        }
9    });
10}
More examples
Hide additional examples
examples/config.rs (line 15)
4fn main() {
5    let config = simple_tqdm::Config::new()
6        .with_desc("[]")
7        .with_total(500)
8        .with_disable(false)
9        .with_leave(true)
10        .with_unit("num")
11        .with_scale(0.5)
12        .with_postfix("hi")
13        .with_color("cyan")
14        .with_disable(true)
15        .with_progress_chars(">= ");
16
17    for _ in (0..250).tqdm_config(config) {
18        std::thread::sleep(Duration::from_millis(10));
19    }
20}

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

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

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Config

Source§

fn partial_cmp(&self, other: &Config) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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