Crate kyuri

Crate kyuri 

Source
Expand description

A simple progress display library.

Kyuri is a simple progress display library. Different from indicatif, it:

  • Depends on std only when terminal support is unnecessary.
    • Custom features console_width and unicode are available for ANSI mode terminal width detection and Unicode width calculation.
  • The Manager (like MultiProgress in indicatif) manages all progress bar management and rendering.
  • Friendly to writing to files.
  • Predictable about when it would draw.
  • Custom integrations with other libraries (an example: examples/tracing.rs)

§Examples

use kyuri::Manager;

const TEMPLATE: &str = "{msg}: {bar} ({pos}/{len})";
let manager = Manager::new(std::time::Duration::from_secs(1));

let bar = manager.create_bar(100, "Processing", TEMPLATE, true);
for i in 0..=100 {
    bar.set_pos(i);
    std::thread::sleep(std::time::Duration::from_millis(1));
}
bar.finish_and_drop();

§Template

The template in Kyuri looks like the one in indicatif. However, only a very small subset is implemented, and some have different meanings.

Tags in template looks like {something}. Supported tags:

  • {msg}, {message}: The message of the bar.
  • {elapsed}, {elapsed_precise}: The elapsed time (H:MM:SS).
  • {bytes}: The current position in bytes (power-of-two, KiB, MiB, …).
  • {pos}: The current position.
  • {total_bytes}: The total length in bytes (power-of-two, KiB, MiB, …).
  • {total}, {len}: The total length.
  • {bytes_per_sec}, {bytes_per_second}: The current speed in bytes per second.
  • {eta}: The estimated time of arrival (H:MM:SS).
  • {bar}, {barNUM}: The progress bar. The NUM is the size of the bar, default is 20.
  • {state_emoji}: The state emoji of the bar. ✅ for finished, 🆕 for new, 💥 for overflowed, ⏳ for in progress.

Doubled { and } would not be interpreted as tags.

Modules§

writer
The modules contains KyuriWriter, a wrapper used with other libraries.

Structs§

Bar
A handle for users to control a progress bar created by Manager.
Manager
The manager for progress bars. It’s expected for users to create a Manager, create progress bars from it, and drop it when all work has been done.

Traits§

Out
Trait for progress output streams. std::io::stdout, std::io::stderr and std::fs::File implement this trait.