ConsoleProgressPrinter

Struct ConsoleProgressPrinter 

Source
pub struct ConsoleProgressPrinter { /* private fields */ }

Implementations§

Source§

impl ConsoleProgressPrinter

Source

pub fn new_update_rate(update_rate: Duration) -> ConsoleProgressPrinter

Examples found in repository?
examples/progress.rs (line 11)
8pub fn main() -> Result<(), std::io::Error> {
9    let elements = 1000;
10
11    let prog = ConsoleProgressPrinter::new_update_rate(Duration::from_millis(100));
12    let task = Task::new(0, "Test Task".to_string(), u64::MAX);
13    prog.track_task_progress(&task);
14    task.mark_started();
15    for i in 0..elements {
16        task.mark_one_completed();
17
18        let status = format!("Phase {}", i / 100);
19        task.set_current_status(Some(status));
20
21        std::thread::sleep(std::time::Duration::from_millis(5));
22    }
23
24    Ok(())
25}
More examples
Hide additional examples
examples/progress_random_write.rs (line 18)
15pub fn main() -> Result<(), Error> {
16    let mut rand = Random::default();
17
18    let cons = ConsoleProgressPrinter::new_update_rate(Duration::from_millis(100));
19    let task = Task::new_infinite_named("Writer".to_string());
20    cons.track_task_progress(&task);
21    task.mark_started();
22
23    let out = OpenOptions::new()
24        .write(true)
25        .truncate(true)
26        .create(true)
27        .open("test")?;
28    let out = BufWriter::new(out);
29    let mut out = WriterTask::new(out, task);
30
31    let gb = 1_000_000_000 / 8;
32    for _i in 0..gb {
33        out.write_be_u64(rand.next_u64())?;
34    }
35
36    Ok(())
37}

Trait Implementations§

Source§

impl Drop for ConsoleProgressPrinter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl ProgressPrinter for ConsoleProgressPrinter

Source§

fn track_task_progress(&self, task: &Task)

Track and display the progress for this specific task.

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> MaybeInto<U> for T
where U: MaybeFrom<T>,

Source§

fn maybe_into(self) -> Option<U>

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.