Crates.io | utls |
lib.rs | utls |
version | |
source | src |
created_at | 2024-12-06 19:18:29.611446 |
updated_at | 2024-12-12 20:26:05.677359 |
description | A simple utilities library for stuff I actually use sometimes, with a large focus on convenience and lack of dependencies. |
homepage | |
repository | https://github.com/barely-a-dev/utls |
max_upload_size | |
id | 1474572 |
Cargo.toml error: | TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A Rust utility library providing thread-safe progress bars and value watching functionality.
Progress Bars: Highly customizable, thread-safe progress bars with:
Value Watcher: Thread-safe value monitoring system
use utls::prog::PB;
use std::thread;
use std::time::Duration;
fn main() {
let pb = PB::modern(100); // Create a modern style progress bar with 100 steps
let (handle, pb_ref) = pb.threaded_start(); // Start the bar rendering in a new thread
PB::inc_until_arc(pb_ref.clone(), || { // Run the Fn closure then increment until the bar finishes
thread::sleep(Duration::from_millis(10)); // (or some work)
});
handle.join().unwrap();
pb_ref.lock().unwrap().finish_with_message("Complete!");
}
use utls::watcher::Watcher;
use std::sync::{atomic::AtomicBool, Arc, Mutex};
fn main() {
let shutdown = Arc::new(Mutex::new(AtomicBool::new(false)));
let watcher = Watcher::new(0, 100, shutdown); // Initial value 0, poll every 100ms
watcher.set_value(42);
if watcher.has_changed() {
println!("Value changed to: {}", watcher.get_value());
}
}
PB::classic()
- Traditional ASCII stylePB::modern()
- Unicode blocks stylePB::minimal()
- Minimalistic appearancePB::fancy()
- Decorative Unicode stylePB::ascii()
- Pure ASCII charactersPB::dots()
- Braille pattern stylePB::arrows()
- Arrow-based stylePB::box_heavy()
- Heavy box drawing charactersProgress bars support the following template variables in messages if formatting is enabled:
{p}
- Progress percentage{c}
- Current value{m}
- Maximum value{e}
- Elapsed time{r}
- Estimated remaining time (highly inaccurate)Requires Rust nightly due to #![feature(unboxed_closures)]
.
See the /examples
directory for more usage examples: