Progress

Struct Progress 

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

Implementations§

Source§

impl Progress

Source

pub fn new<S: Into<String>>(message: S) -> Self

Examples found in repository?
examples/progress.rs (line 7)
5fn main() {
6    // Basic progress without total
7    let mut progress = Progress::new("Processing");
8    for _ in 0..5 {
9        thread::sleep(Duration::from_millis(300));
10        progress.inc(1);
11    }
12    progress.finish();
13
14    // Progress with total
15    let mut progress = Progress::with_total("Downloading", 100);
16    for i in 0..=10 {
17        thread::sleep(Duration::from_millis(100));
18        progress.inc(10);
19        progress.update(format!("Downloading chunk {}/10", i));
20    }
21    progress.finish_with_message("Download complete!");
22
23    // Multiple progress indicators
24    let mut scan = Progress::with_total("Port scan", 1000);
25    let mut analysis = Progress::new("Analyzing results");
26
27    for i in (0..=1000).step_by(100) {
28        thread::sleep(Duration::from_millis(50));
29        scan.inc(100);
30        if i % 200 == 0 {
31            analysis.inc(1);
32        }
33    }
34
35    scan.finish();
36    analysis.finish_with_message("Analysis complete - Found 5 open ports");
37}
Source

pub fn with_total<S: Into<String>>(message: S, total: u64) -> Self

Examples found in repository?
examples/progress.rs (line 15)
5fn main() {
6    // Basic progress without total
7    let mut progress = Progress::new("Processing");
8    for _ in 0..5 {
9        thread::sleep(Duration::from_millis(300));
10        progress.inc(1);
11    }
12    progress.finish();
13
14    // Progress with total
15    let mut progress = Progress::with_total("Downloading", 100);
16    for i in 0..=10 {
17        thread::sleep(Duration::from_millis(100));
18        progress.inc(10);
19        progress.update(format!("Downloading chunk {}/10", i));
20    }
21    progress.finish_with_message("Download complete!");
22
23    // Multiple progress indicators
24    let mut scan = Progress::with_total("Port scan", 1000);
25    let mut analysis = Progress::new("Analyzing results");
26
27    for i in (0..=1000).step_by(100) {
28        thread::sleep(Duration::from_millis(50));
29        scan.inc(100);
30        if i % 200 == 0 {
31            analysis.inc(1);
32        }
33    }
34
35    scan.finish();
36    analysis.finish_with_message("Analysis complete - Found 5 open ports");
37}
Source

pub fn inc(&mut self, amount: u64)

Examples found in repository?
examples/progress.rs (line 10)
5fn main() {
6    // Basic progress without total
7    let mut progress = Progress::new("Processing");
8    for _ in 0..5 {
9        thread::sleep(Duration::from_millis(300));
10        progress.inc(1);
11    }
12    progress.finish();
13
14    // Progress with total
15    let mut progress = Progress::with_total("Downloading", 100);
16    for i in 0..=10 {
17        thread::sleep(Duration::from_millis(100));
18        progress.inc(10);
19        progress.update(format!("Downloading chunk {}/10", i));
20    }
21    progress.finish_with_message("Download complete!");
22
23    // Multiple progress indicators
24    let mut scan = Progress::with_total("Port scan", 1000);
25    let mut analysis = Progress::new("Analyzing results");
26
27    for i in (0..=1000).step_by(100) {
28        thread::sleep(Duration::from_millis(50));
29        scan.inc(100);
30        if i % 200 == 0 {
31            analysis.inc(1);
32        }
33    }
34
35    scan.finish();
36    analysis.finish_with_message("Analysis complete - Found 5 open ports");
37}
Source

pub fn update<S: Into<String>>(&mut self, message: S)

Examples found in repository?
examples/progress.rs (line 19)
5fn main() {
6    // Basic progress without total
7    let mut progress = Progress::new("Processing");
8    for _ in 0..5 {
9        thread::sleep(Duration::from_millis(300));
10        progress.inc(1);
11    }
12    progress.finish();
13
14    // Progress with total
15    let mut progress = Progress::with_total("Downloading", 100);
16    for i in 0..=10 {
17        thread::sleep(Duration::from_millis(100));
18        progress.inc(10);
19        progress.update(format!("Downloading chunk {}/10", i));
20    }
21    progress.finish_with_message("Download complete!");
22
23    // Multiple progress indicators
24    let mut scan = Progress::with_total("Port scan", 1000);
25    let mut analysis = Progress::new("Analyzing results");
26
27    for i in (0..=1000).step_by(100) {
28        thread::sleep(Duration::from_millis(50));
29        scan.inc(100);
30        if i % 200 == 0 {
31            analysis.inc(1);
32        }
33    }
34
35    scan.finish();
36    analysis.finish_with_message("Analysis complete - Found 5 open ports");
37}
Source

pub fn finish(self)

Examples found in repository?
examples/progress.rs (line 12)
5fn main() {
6    // Basic progress without total
7    let mut progress = Progress::new("Processing");
8    for _ in 0..5 {
9        thread::sleep(Duration::from_millis(300));
10        progress.inc(1);
11    }
12    progress.finish();
13
14    // Progress with total
15    let mut progress = Progress::with_total("Downloading", 100);
16    for i in 0..=10 {
17        thread::sleep(Duration::from_millis(100));
18        progress.inc(10);
19        progress.update(format!("Downloading chunk {}/10", i));
20    }
21    progress.finish_with_message("Download complete!");
22
23    // Multiple progress indicators
24    let mut scan = Progress::with_total("Port scan", 1000);
25    let mut analysis = Progress::new("Analyzing results");
26
27    for i in (0..=1000).step_by(100) {
28        thread::sleep(Duration::from_millis(50));
29        scan.inc(100);
30        if i % 200 == 0 {
31            analysis.inc(1);
32        }
33    }
34
35    scan.finish();
36    analysis.finish_with_message("Analysis complete - Found 5 open ports");
37}
Source

pub fn finish_with_message<S: Into<String>>(self, message: S)

Examples found in repository?
examples/progress.rs (line 21)
5fn main() {
6    // Basic progress without total
7    let mut progress = Progress::new("Processing");
8    for _ in 0..5 {
9        thread::sleep(Duration::from_millis(300));
10        progress.inc(1);
11    }
12    progress.finish();
13
14    // Progress with total
15    let mut progress = Progress::with_total("Downloading", 100);
16    for i in 0..=10 {
17        thread::sleep(Duration::from_millis(100));
18        progress.inc(10);
19        progress.update(format!("Downloading chunk {}/10", i));
20    }
21    progress.finish_with_message("Download complete!");
22
23    // Multiple progress indicators
24    let mut scan = Progress::with_total("Port scan", 1000);
25    let mut analysis = Progress::new("Analyzing results");
26
27    for i in (0..=1000).step_by(100) {
28        thread::sleep(Duration::from_millis(50));
29        scan.inc(100);
30        if i % 200 == 0 {
31            analysis.inc(1);
32        }
33    }
34
35    scan.finish();
36    analysis.finish_with_message("Analysis complete - Found 5 open ports");
37}

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.