ProgressBar

Struct ProgressBar 

Source
pub struct ProgressBar<'a> {
    pub current: u32,
    pub max: u32,
    pub max_time: u32,
    pub style: Style<'a>,
}
Expand description

This is the progress bar struct

ยงUsage

use pgbar::{ProgressBar, Style};
use termion::color;

let mut progress_bar = ProgressBar::new(100, 10, Style {
   symbol: String::from("*"), // The progress bar will be filled with *
   color: Some(&color::Cyan), // This is the color of the progress bar
   width: 50, // This is the width of the progress bar
   time_to_finish: true, // This is the time to finish the progress bar
   wrapper: String::from("[]"), // This is the wrapper of the progress bar
});

progress_bar.track(); // This will start the progress bar
progress_bar.update(50); // This will update the progress bar
progress_bar.finish(); // This will finish the progress bar
progress_bar.recover(); // This will recover the progress bar
progress_bar.reset(); // This will reset the progress bar to 0

Fieldsยง

ยงcurrent: u32

The current progress

ยงmax: u32

The max progress

ยงmax_time: u32

The max time to finish the progress bar in seconds

ยงstyle: Style<'a>

The style of the progress bar defined in the Style struct

Implementationsยง

Sourceยง

impl ProgressBar<'_>

Source

pub fn new(max: u32, max_time: u32, style: Style<'_>) -> ProgressBar<'_>

This is the constructor of the progress bar

Source

pub fn track(&mut self)

[track]

This method is used to start the progress bar

Source

pub fn finish(&mut self)

[finish]

This method is used to finish the progress bar

Source

pub fn update(&mut self, current: u32)

[update] This method is used to update the progress bar

Source

pub fn reset(&mut self)

[reset]

This method is used to reset the progress bar

Source

pub fn recover(&mut self)

[recover]

This method is used to recover the progress bar

Auto Trait Implementationsยง

ยง

impl<'a> Freeze for ProgressBar<'a>

ยง

impl<'a> !RefUnwindSafe for ProgressBar<'a>

ยง

impl<'a> !Send for ProgressBar<'a>

ยง

impl<'a> !Sync for ProgressBar<'a>

ยง

impl<'a> Unpin for ProgressBar<'a>

ยง

impl<'a> !UnwindSafe for ProgressBar<'a>

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.