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
impl Progress
pub fn new<S: Into<String>>(caption: S, start: usize, end: usize) -> Self
pub fn new_with_width<S>( caption: S, start: usize, end: usize, width: u16, ) -> Self
Sourcepub fn current(&self) -> usize
pub fn current(&self) -> usize
Returns the current progress absolute value.
§Example
use progress::Progress;
let p = Progress::default();
assert_eq!(0, p.current());
Sourcepub fn total(&self) -> usize
pub fn total(&self) -> usize
Returns the total value.
§Example
use progress::Progress;
let p = Progress::default();
assert_eq!(100, p.total());
Sourcepub fn forward(&mut self, step: usize) -> &Self
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());
Sourcepub fn backward(&mut self, step: usize) -> &Self
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());
Trait Implementations§
Source§impl AddAssign<usize> for Progress
impl AddAssign<usize> for Progress
Source§fn add_assign(&mut self, step: usize)
fn add_assign(&mut self, step: usize)
Performs the
+=
operation. Read moreAuto 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