pub struct BarManager<'bar> { /* private fields */ }
Expand description

Manager for all current progress bars and text output.

This can be used, with the new_bar method and the println! and print! (crate) macros to display progress bars and even print while doing so

to display the bar, simply call .print(). in adition, the bar will be automaticaly printed when using the print! and println! macros.

Please note that you currently cannot use more than one bar type in a manager. this may change in the future as it is kinda a problem, but fixing it would have some tradeoffs

Examples

simple bar

use std::thread;

use stati::BarManager;
use stati::prelude::*;

let mut manager = BarManager::new();
let mut bar = manager.register_bar(stati::bars::SimpleBar::new("Working...".into(), ()));
for i in 0..=100 {
    bar.set_progress(i);
    manager.print();
    thread::sleep_ms(40);
}

printing while using progress bar

use std::thread;

use stati::BarManager;
use stati::prelude::*;

let mut manager = BarManager::new();
let mut bar = manager.register_bar(stati::bars::SimpleBar::new("Working...".into(), ()));
for i in 0..=100 {
    bar.set_progress(i);
    stati::println!(manager, "Progressed to {} in the first section", i);
    manager.print();
    thread::sleep_ms(40);
}

A note on ANSI controll charecters

The way that this uses these charecters to re-print bars is rather finicky, and if you use ANSI text while using this, it probably will work, but could also break and cause hard to debug errors.

Thread Saftey

n o

Implementations

Creates a new BarManager

Registers a progress bar with the bar manager, to be drawn with the manager. Returns what is effectively a reference to it, and when that refference is dropped or .done() is called, the bar is finished, and is completed according to bar.close_method()

Flushes updates to stdout.

Currently this only flushes stdout, but will hopefully do more in the future

Panics

if stdout cannot be flushed

for a non-panicing alternative, see BarManager::try_flush

Queues text to be printed before the bars. this should NOT be use directly, but should be used with the println! and print! macros

this does NOT immediataly print the text

Prints the bar status and any queued text to stdout, and flushes it.

Panics

if stdout cannot be flushed

for a non-panicing alternative, see BarManager::try_print

Prints the bar status and any queued text to stdout, without flushing it

Trait Implementations

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.