[][src]Struct logbar::ProgressBar

pub struct ProgressBar { /* fields omitted */ }

A log-friendly progress bar

Methods

impl ProgressBar[src]

pub fn new(max_progress: usize) -> Self[src]

Create a new progress bar with default style

Example

let max_progress = 100;
let bar = logbar::ProgressBar::new(max_progress);

pub fn with_style(max_progress: usize, style: Style) -> Self[src]

Create a new progress bar with custom style

Example

Create a progress bar with a width of 80 characters:

let style = logbar::Style::new().width(80);
let max_progress = 100;
let bar = logbar::ProgressBar::with_style(max_progress, style);

pub fn style(&self) -> &Style[src]

Get the style of the current progress bar

Example

let max_progress = 100;
let bar = logbar::ProgressBar::new(max_progress);
assert_eq!(bar.style(), &logbar::Style::default())

pub fn inc(&self, i: usize)[src]

Increment the progress

This method increments the internal progress counter, up to the maximum defined during the construction of the progress bar. It then updates the progress display.

Example

let max_progress = 50;
let bar = logbar::ProgressBar::new(max_progress);
bar.inc(10); // Increment progress to 10 out of 50.
// The progress bar is at 20% now
bar.inc(10); // Increment progress to 20 out of 50.
// The progress bar is at 40% now
bar.inc(100); // Increment progress to 50 out of 50.
// The progress bar is at 100% now

pub fn finish(&self)[src]

Finish the progress bar

This method sets the progress to 100% and moves to the next line after the progress bar

Example

let max_progress = 50;
let bar = logbar::ProgressBar::new(max_progress);
bar.finish();
// The progress bar is at 100% now

Trait Implementations

impl Debug for ProgressBar[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.