pub struct ProgressBar<T: Write> {
pub total: u64,
pub is_finish: bool,
pub is_multibar: bool,
pub show_bar: bool,
pub show_speed: bool,
pub show_percent: bool,
pub show_counter: bool,
pub show_time_left: bool,
pub show_tick: bool,
pub show_message: bool,
/* private fields */
}Fields§
§total: u64§is_finish: bool§is_multibar: bool§show_bar: bool§show_speed: bool§show_percent: bool§show_counter: bool§show_time_left: bool§show_tick: bool§show_message: boolImplementations§
Source§impl ProgressBar<Stdout>
impl ProgressBar<Stdout>
Sourcepub fn new(total: u64) -> ProgressBar<Stdout> ⓘ
pub fn new(total: u64) -> ProgressBar<Stdout> ⓘ
Create a new ProgressBar with default configuration.
§Examples
use std::thread;
use pbr::{ProgressBar, Units};
let count = 1000;
let mut pb = ProgressBar::new(count);
pb.set_units(Units::Bytes);
for _ in 0..count {
pb.inc();
thread::sleep_ms(100);
}Source§impl<T: Write> ProgressBar<T>
impl<T: Write> ProgressBar<T>
Sourcepub fn on(handle: T, total: u64) -> ProgressBar<T> ⓘ
pub fn on(handle: T, total: u64) -> ProgressBar<T> ⓘ
Create a new ProgressBar with default configuration but pass an arbitrary writer.
§Examples
use std::thread;
use std::io::stderr;
use pbr::{ProgressBar, Units};
let count = 1000;
let mut pb = ProgressBar::on(stderr(), count);
pb.set_units(Units::Bytes);
for _ in 0..count {
pb.inc();
thread::sleep_ms(100);
}Sourcepub fn set_units(&mut self, u: Units)
pub fn set_units(&mut self, u: Units)
Set units, default is simple numbers
§Examples
use pbr::{ProgressBar, Units};
let n_bytes = 100;
let mut pb = ProgressBar::new(n_bytes);
pb.set_units(Units::Bytes);Sourcepub fn message(&mut self, message: &str)
pub fn message(&mut self, message: &str)
Set message to display in the prefix, call with “” to stop printing a message.
All newlines are replaced with spaces.
§Examples
let mut pb = ProgressBar::new(20);
for x in 0..20 {
match x {
0 => pb.message("Doing 1st Quarter"),
5 => pb.message("Doing 2nd Quarter"),
10 => pb.message("Doing 3rd Quarter"),
15 => pb.message("Doing 4th Quarter"),
}
pb.inc().
}
Sourcepub fn tick_format(&mut self, tick_fmt: &str)
pub fn tick_format(&mut self, tick_fmt: &str)
Sourcepub fn set_max_refresh_rate(&mut self, w: Option<Duration>)
pub fn set_max_refresh_rate(&mut self, w: Option<Duration>)
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Update progress bar even though no progress are made Useful to see if a program is bricked or just not doing any progress.
tick is not needed with add or inc as performed operation take place in draw function.
§Examples
let mut pb = ProgressBar::new(...);
pb.inc();
for _ in ... {
...do something
pb.tick();
}
pb.finish();Sourcepub fn add(&mut self, i: u64) -> u64
pub fn add(&mut self, i: u64) -> u64
Add to current value
§Examples
use pbr::ProgressBar;
let mut pb = ProgressBar::new(10);
pb.add(5);
pb.finish();Sourcepub fn set(&mut self, i: u64) -> u64
pub fn set(&mut self, i: u64) -> u64
Manually set the current value of the bar
§Examples
use pbr::ProgressBar;
let mut pb = ProgressBar::new(10);
pb.set(8);
pb.finish();Sourcepub fn reset_start_time(&mut self)
pub fn reset_start_time(&mut self)
Resets the start time to now
Sourcepub fn finish(&mut self)
pub fn finish(&mut self)
Calling finish manually will set current to total and draw the last time
Sourcepub fn finish_print(&mut self, s: &str)
pub fn finish_print(&mut self, s: &str)
Call finish and write string s that will replace the progress bar.
Sourcepub fn finish_println(&mut self, s: &str)
pub fn finish_println(&mut self, s: &str)
Call finish and write string s below the progress bar.
If the ProgressBar is part of MultiBar instance, you should use
finish_print to print message.
Trait Implementations§
Source§impl<T: Write> Write for ProgressBar<T>
impl<T: Write> Write for ProgressBar<T>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)