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
ProgressBuilder
withprogress_builder!
macro, setting custom options, and then creatingProgress
withbuild
.
Progress
is drawn
- using background thread to guarantee timely updates
- only if terminal is detected
- to
STDERR
starting with"\r"
- from the moment
Progress
is created untilProgress
is finished or dropped
Implementations§
Source§impl Progress
impl Progress
Sourcepub fn finish(&self)
pub fn finish(&self)
Finishes Progress
with 100% completion.
- Sets
State
ofProgress
to 100% completion. - Draws
Progress
once 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)
End
Sourcepub fn finish_and_clear(&self)
pub fn finish_and_clear(&self)
Finishes and clears Progress
.
- Clears drawn
Progress
by 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
End
Sourcepub fn finish_at_current_pos(&self)
pub fn finish_at_current_pos(&self)
Finishes Progress
.
- Draws
Progress
once 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)
End
Sourcepub 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