Struct Progress

Source
pub struct Progress { /* private fields */ }
Expand description

Progress indicator.

Progress is created either

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 until Progress is finished or dropped

See crate index for usage and examples.

Implementations§

Source§

impl Progress

Source

pub fn finish(&self)

Finishes Progress with 100% completion.

  • Sets State of Progress 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
Source

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
Source

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
Source

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)
Source

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!
Source

pub fn state(&self) -> &Arc<Mutex<State>>

Returns current state of Progress.

§Examples
use ml_progress::progress;

let progress = progress!(10)?;
progress.inc(6);
assert_eq!(progress.state().lock().pos(), 6);

Trait Implementations§

Source§

impl Clone for Progress

Source§

fn clone(&self) -> Progress

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Progress

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.