pub struct Manager { /* private fields */ }Expand description
The manager for progress bars. It’s expected for users to create a Manager, create progress bars from it,
and drop it when all work has been done.
When manager is dropped, it would force a draw. After that bars would not be able to be interacted with.
Implementations§
Source§impl Manager
impl Manager
Sourcepub fn new(interval: Duration) -> Self
pub fn new(interval: Duration) -> Self
Create a new Manager to stdout.
The interval parameter specifies the minimum interval between two unforced draws.
Sourcepub fn with_stdout(self) -> Self
pub fn with_stdout(self) -> Self
Set the Manager to write to stdout.
Sourcepub fn with_stderr(self) -> Self
pub fn with_stderr(self) -> Self
Set the Manager to write to stderr.
Sourcepub fn auto_ansi(self) -> Self
pub fn auto_ansi(self) -> Self
Let Manager automatically detect whether it’s writing to a terminal and use ANSI or not.
Sourcepub fn force_ansi(self, force: bool) -> Self
pub fn force_ansi(self, force: bool) -> Self
Force Manager to use ANSI escape codes or not.
Sourcepub fn set_ticker(&self, set_ticker: bool)
pub fn set_ticker(&self, set_ticker: bool)
Ticker enables a background thread to draw progress bars at a fixed interval.
When ticker is enabled, unforced draw would be ignored.
Sourcepub fn create_bar(
&self,
len: u64,
message: &str,
template: &str,
visible: bool,
) -> Bar
pub fn create_bar( &self, len: u64, message: &str, template: &str, visible: bool, ) -> Bar
Create a new progress bar.
len: The total length of the progress bar.message: The message of the bar. Use{msg}in the template to refer to this.template: The template of the bar.visible: Whether the bar is visible.
This makes a forced draw when visible is true.
Sourcepub fn draw(&self, force: bool)
pub fn draw(&self, force: bool)
Draw all progress bars. In most cases it’s not necessary to call this manually.
If nothing changed, it would not draw no matter what.
If ticker is enabled, unforced draw would be ignored. Otherwise, it would only draw when the interval has passed.
Progress bars would be drawn by the order of Bar creation. In ANSI mode, it would clear the previous output.
Finally, when output is not a terminal, bars would be drawn only when it needs to be redrawn.
Sourcepub fn suspend<F: FnOnce(&mut Box<dyn Out>) -> R, R>(&self, f: F) -> R
pub fn suspend<F: FnOnce(&mut Box<dyn Out>) -> R, R>(&self, f: F) -> R
Hide all progress bars, run the closure, and show them again like indicatif::MultiProgress::suspend.
This method is used for implementing integrations with other libraries that may print to the terminal.
When output is not a terminal, the closure would still be run but nothing would be done to the progress bars.
Sourcepub fn create_writer(&self) -> KyuriWriter
pub fn create_writer(&self) -> KyuriWriter
Create a writer for integration with other libraries.