pub trait BarExt {
// Required methods
fn clear(&mut self) -> Result<()>;
fn input<T: Into<String>>(&mut self, text: T) -> Result<String>;
fn refresh(&mut self) -> Result<()>;
fn render(&mut self) -> String;
fn reset(&mut self, total: Option<usize>);
fn update(&mut self, n: usize) -> Result<bool>;
fn update_to(&mut self, n: usize) -> Result<bool>;
fn write<T: Into<String>>(&mut self, text: T) -> Result<()>;
fn write_to<T: Write>(
&mut self,
writer: &mut T,
n: Option<usize>,
) -> Result<bool>;
}Expand description
Comman progress bar functionalities shared between different types of progress bars.
Required Methods§
Sourcefn clear(&mut self) -> Result<()>
fn clear(&mut self) -> Result<()>
Clear current progress bar display.
Returns Err, if writing to handle fails.
Sourcefn input<T: Into<String>>(&mut self, text: T) -> Result<String>
fn input<T: Into<String>>(&mut self, text: T) -> Result<String>
Take input via progress bar (without overlaping with bar(s)).
Returns Err, if reading from stdin handle fails.
Sourcefn refresh(&mut self) -> Result<()>
fn refresh(&mut self) -> Result<()>
Force refresh current progress bar display.
Returns Err, if writing to handle fails.
Sourcefn reset(&mut self, total: Option<usize>)
fn reset(&mut self, total: Option<usize>)
Resets counter to 0 for repeated use.
Consider combining with leave = true.
Sourcefn update(&mut self, n: usize) -> Result<bool>
fn update(&mut self, n: usize) -> Result<bool>
Manually update the progress bar, useful for streams such as reading files.
Returns whether an update was triggered or not depending on constraints.
Returns Err, if writing to handle fails.
Sourcefn update_to(&mut self, n: usize) -> Result<bool>
fn update_to(&mut self, n: usize) -> Result<bool>
Set counter value instead of incrementing counter through update method.
Returns wheter a update was triggered or not depending on constraints.
Returns Err, if writing to handle fails.
Sourcefn write<T: Into<String>>(&mut self, text: T) -> Result<()>
fn write<T: Into<String>>(&mut self, text: T) -> Result<()>
Print a message via progress bar (without overlaping with bar(s)).
Returns Err, if writing to handle fails.
Sourcefn write_to<T: Write>(
&mut self,
writer: &mut T,
n: Option<usize>,
) -> Result<bool>
fn write_to<T: Write>( &mut self, writer: &mut T, n: Option<usize>, ) -> Result<bool>
Write progress bar rendered text to a writer (useful for writing files).
If n is supplied then this method behaves like update method.
Returns whether a update was triggered or not depending on constraints.
Returns Err, if writing to handle fails.
§Example
use kdam::{tqdm, BarExt};
use std::{fs::File, io::Write};
let mut pb = tqdm!(total = 100, animation = "ascii");
let mut f = File::create("kdam-logs.txt").unwrap();
for i in 1..101 {
pb.counter = i;
pb.write_to(&mut f, Some(0));
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".