2 stable releases
1.1.0 | Jan 10, 2023 |
---|---|
1.0.0 | Dec 30, 2022 |
#4 in #estimating
8KB
152 lines
Chug
Estimate the time remaining for a long-running process.
Installation
cargo add chug
Usage
See examples/tick.rs for a simple example.
License
MIT
lib.rs
:
A library for estimating the time remaining until a task is completed.
Example
use chug::Chug;
let mut chug = Chug::new(10, 100);
for _ in 0..100 {
let formatted_eta = match chug.eta() {
Some(eta) => {
let eta_secs = eta.as_secs();
let eta_millis = eta.subsec_millis();
format!("ETA: {}.{:03}", eta_secs, eta_millis)
}
None => "ETA: None".to_string(),
};
println!("{}", formatted_eta);
// Do some work...
chug.tick();
}