barber 0.1.3

A library for creating and using thread safe and thread-stable progress bars across different frontends and backends
Documentation

Barber

A crate for creating progress bars in rust

Crates.io Crates.io License

Adding to your crate

You can add barber to your crate using:

cargo add barber

About

Barber is a crate for creating and using thread safe and thread-stable progress bars across different frontends and backends

For more information about the types and functions, see the docs

Features

Barber has two very important items, the ProgressBar struct and the ProgressRenderer trait. The separation of these two items is what allows the progress bar to be abstracted, allowing a library to display a progress using any progress bar.

Each progress bar is made 'thread stable' by having each progress bar have its own thread for managing its values. This means you can increment the counter using multiple threads and still get a sequential ordering

ProgressBar

The ProgressBar struct is what most people will think of when they want a progress bar, something they can set max/min values for, increment, set the value of, label, etc.

The two major functions are:

  • new() : Creates a new ProgressBar that renders using the input ProgressRenderer
  • increment() : Increments the progress bar by 1

ProgressRenderer

The ProgressRenderer trait defines how to render a progress bar.

The three major functions are:

  • on_start() : This function is called when a new ProgressBar is created using it.
  • on_update() : This function is called when the bar is updated.
  • on_finish() : This function is called when the ProgressBar holding the ProgressRenderer is dropped.

NullProgressRenderer

The NullProgressRenderer is a special default ProgressRenderer implementation for when something requires a progress bar, but you don't want to display anything. This render will not spawn any thread for itself, and any attempts to update it will do nothing. It tries to be as light as possible as a 'nothing' progress bar without simply never creating one

Contribution

Contribution is always welcome! I am only a solo developer, I created this crate for my own uses. I enjoy the separation of frontends and backends, the idea that one core library can provide the same functionallity to any caller as simply as possible. This is also why I created a default implementation for the CliProgressRenderer if you use the cli_renderer feature