pub struct Progress { /* private fields */ }Implementations§
Source§impl Progress
impl Progress
Sourcepub fn new<S: Into<String>>(message: S) -> Self
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}Sourcepub fn with_total<S: Into<String>>(message: S, total: u64) -> Self
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}Sourcepub fn inc(&mut self, amount: u64)
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}Sourcepub fn update<S: Into<String>>(&mut self, message: S)
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}Sourcepub fn finish(self)
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}Sourcepub fn finish_with_message<S: Into<String>>(self, message: S)
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§
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