Struct Progress

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

Tracks progress of a task.

There should be not more than a single instance started at a given point in time, it will mangle your terminal output.

Implementations§

Source§

impl Progress

Source

pub fn new<S: Into<String>>(caption: S, start: usize, end: usize) -> Self

Source

pub fn new_with_width<S>( caption: S, start: usize, end: usize, width: u16, ) -> Self
where S: Into<String>,

Source

pub fn current(&self) -> usize

Returns the current progress absolute value.

§Example
use progress::Progress;
let p = Progress::default();
assert_eq!(0, p.current());
Source

pub fn total(&self) -> usize

Returns the total value.

§Example
use progress::Progress;
let p = Progress::default();
assert_eq!(100, p.total());
Source

pub fn forward(&mut self, step: usize) -> &Self

Advances the Progress by a certain amount.

§Examplw
use progress::Progress;
let mut p = Progress::default();
assert_eq!(0, p.current());
p.forward(10);
assert_eq!(10, p.current());
p += 20;
assert_eq!(30, p.current());
Source

pub fn backward(&mut self, step: usize) -> &Self

Advances the Progress by a certain amount.

§Examplw
use progress::Builder;
let mut p = Builder::new().set_start(30).build();
assert_eq!(30, p.current());
p.backward(10);
assert_eq!(20, p.current());
p -= 20;
assert_eq!(0, p.current());
Source

pub fn increment(&mut self) -> &Self

Advances the Progress by exactly one.

Source

pub fn decrement(&mut self) -> &Self

Does a step backwards at the Progress.

Source

pub fn finished(&self) -> bool

Determines wheter a Progress has finished (reached the total) or not.

Source

pub fn process(&self) -> u8

Returns the relative value of the Progress.

Source

pub fn start(&mut self) -> &Self

Activates the Progress.

Source

pub fn caption(&self) -> &String

Returns the current caption.

Trait Implementations§

Source§

impl AddAssign<usize> for Progress

Source§

fn add_assign(&mut self, step: usize)

Performs the += operation. Read more
Source§

impl Default for Progress

Source§

fn default() -> Progress

Returns the “default value” for a type. Read more
Source§

impl SubAssign<usize> for Progress

Source§

fn sub_assign(&mut self, step: usize)

Performs the -= operation. 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> 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.