Progress Bars
Beautiful progress bars with multiple styles and real-time updates
Overview
Display progress with customizable bars and spinners
The progress module provides:
- Multiple progress bar styles
- Real-time progress updates
- Custom messages and formatting
- Percentage and count display
- Smooth animations
Basic Progress Bar
Simple progress bar with updates
Basic Progress Example
use zfish::ProgressBar;
use std::thread;
use std::time::Duration;
let mut pb = ProgressBar::new(100);
for i in 0..=100 {
pb.set(i);
thread::sleep(Duration::from_millis(50));
}
pb.finish("ā Complete!");Output
[========================================] 100.0% (100/100) 2000.0/s ETA: 0.0s\nā Complete!
Incremental Progress
Update progress incrementally with .inc()
Incremental Progress
use zfish::ProgressBar;
use std::time::Duration;
let mut pb = ProgressBar::new(50);
for _ in 0..50 {
pb.inc(1);
std::thread::sleep(Duration::from_millis(30));
}
pb.finish("ā Incremental done!");Output
[========================================] 100.0% (50/50) 1666.7/s ETA: 0.0s\nā Incremental done!
Custom Style
Different progress bar styles
Custom Progress Styles
use zfish::{ProgressBar, ProgressStyle};
// Classic style (default): [========== ]
let mut pb = ProgressBar::new(100);
// Arrow style: [=========> ]
let mut pb = ProgressBar::new(100).with_style(ProgressStyle::Arrow);
// Dots style: [********** ]
let mut pb = ProgressBar::new(100).with_style(ProgressStyle::Dots);
// Spinner style: [/|/|/|/| ]
let mut pb = ProgressBar::new(100).with_style(ProgressStyle::Spinner);
// Custom width
let mut pb = ProgressBar::new(80).width(60);API Reference
Available methods and options
ProgressBar Methods
new(total)Create a new progress bar
set(position)Update progress position
inc(amount)Increment progress by amount
with_style(style)Set progress bar style
width(w)Set bar width in characters
finish(msg)Complete with message