pub struct Progress { /* private fields */ }Expand description
Progress indicator.
Progress is created either
- directly with
progress!macro (if you don’t need custom configuration) or - by first creating
ProgressBuilderwithprogress_builder!macro, setting custom options, and then creatingProgresswithbuild.
Progress is drawn
- using background thread to guarantee timely updates
- only if terminal is detected
- to
STDERRstarting with"\r" - from the moment
Progressis created untilProgressis finished or dropped
Implementations§
Source§impl Progress
impl Progress
Sourcepub fn finish(&self)
pub fn finish(&self)
Finishes Progress with 100% completion.
- Sets
StateofProgressto 100% completion. - Draws
Progressonce with additional"\n"to move cursor to next line. - Finishes
Progress, i.e. there will be no further draws.
§Examples
use ml_progress::progress;
eprintln!("Begin");
let progress = progress!(10)?;
progress.finish();
eprintln!("End");Begin
################################################# 10/10 (0s)
EndSourcepub fn finish_and_clear(&self)
pub fn finish_and_clear(&self)
Finishes and clears Progress.
- Clears drawn
Progressby overwriting with spaces +"\r", leaving cursor at start of the cleared line. - Finishes
Progress, i.e. there will be no further draws.
§Examples
use ml_progress::progress;
eprintln!("Begin");
let progress = progress!(10)?;
progress.finish_and_clear();
eprintln!("End");Begin
EndSourcepub fn finish_at_current_pos(&self)
pub fn finish_at_current_pos(&self)
Finishes Progress.
- Draws
Progressonce with additional"\n"to move cursor to next line. - Finishes
Progress, i.e. there will be no further draws.
§Examples
use ml_progress::progress;
eprintln!("Begin");
let progress = progress!(10)?;
progress.inc(6);
progress.finish_at_current_pos();
eprintln!("End");Begin
##############################-------------------- 6/10 (0s)
EndSourcepub fn inc(&self, steps: u64)
pub fn inc(&self, steps: u64)
Increments position of Progress.
§Examples
use ml_progress::progress;
let progress = progress!(10)?;
progress.inc(6);
progress.finish_at_current_pos();##############################-------------------- 6/10 (0s)Sourcepub fn message(&self, message: impl Into<Cow<'static, str>>)
pub fn message(&self, message: impl Into<Cow<'static, str>>)
Sets the message shown by item message_fill.
§Examples
use ml_progress::progress;
let progress = progress!(10; pos "/" total " " message_fill)?;
progress.inc(6);
progress.message("Hello, World!");
progress.finish_at_current_pos();6/10 Hello, World!Trait Implementations§
Auto Trait Implementations§
impl Freeze for Progress
impl !RefUnwindSafe for Progress
impl Send for Progress
impl Sync for Progress
impl Unpin for Progress
impl !UnwindSafe for Progress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more