Struct State

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

Current state of Progress.

This is used with custom item and returned by Progress::state.

See custom item for an example.

Implementations§

Source§

impl State

Source

pub fn eta(&self) -> Option<Duration>

Returns estimated time remaining or None if estimate is not available.

Estimate is based on completed steps and time of latest completion.

Estimate is available if

  • total is Some and
  • at least one step and at most total steps have been completed and
  • at least 100 ms has elapsed since Progress creation.

See custom item for an example.

Source

pub fn percent(&self) -> Option<f64>

Returns percentual completion or None if total is None.

Returned value can be over 100 if position is incremented beyond total.

§Examples
use ml_progress::progress;

let progress = progress!(10)?;
progress.inc(6);
assert_eq!(progress.state().lock().percent(), Some(60.0));
Source

pub fn pos(&self) -> u64

Returns position.

§Examples
use ml_progress::progress;

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

pub fn speed(&self) -> Option<f64>

Returns speed in steps per second or None if speed is not available.

Speed is average from when Progress was created until latest inc.

Speed is available if

  • at least one step has been completed and
  • at least 100 ms has elapsed since Progress creation.
Source

pub fn thousands_separator(&self) -> &str

Returns thousands separator.

Separator can be set with ProgressBuilder::thousands_separator, default is space.

§Examples
use ml_progress::progress_builder;

let progress = progress_builder!().thousands_separator(",").build()?;
assert_eq!(progress.state().lock().thousands_separator(), ",");
Source

pub fn total(&self) -> Option<u64>

Returns total.

§Examples
use ml_progress::progress;

let progress = progress!(10)?;
assert_eq!(progress.state().lock().total(), Some(10));

Auto Trait Implementations§

§

impl Freeze for State

§

impl !RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl !UnwindSafe for State

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> 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, 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.