onde-tqdm 0.8.2

Python tqdm in Rust
Documentation
//! Progress bar style enumeration
//!
//! - `ASCII`: Pure ASCII bar with `"0123456789#"`
//! - `Block`: Common bar with unicode characters `" ▏▎▍▌▋▊▉█"`
//! - `Balloon`: Simulate balloon explosion with `".oO@*"`. Inspired by [stackoverflow](https://stackoverflow.com/a/2685509/17570263)
//! - `Pacman`: Inspired by Arch Linux ILoveCandy
//! - `Custom`: Create a custom progressbar style
//!
//! Other styles are open for [contribution](https://github.com/mrlazy1708/tqdm/issues/1).

#[derive(Clone, Debug)]
pub enum Colour {
    None,
    Red,
    Green,
    Yellow,
    Blue,
    Magenta,
    Cyan,
}

impl Colour {
    pub fn ansi_code(&self) -> &str {
        match self {
            Colour::None => "",
            Colour::Red => "\x1b[31m",
            Colour::Green => "\x1b[32m",
            Colour::Yellow => "\x1b[33m",
            Colour::Blue => "\x1b[34m",
            Colour::Magenta => "\x1b[35m",
            Colour::Cyan => "\x1b[36m",
        }
    }

    pub fn reset() -> &'static str {
        "\x1b[0m"
    }
}

impl Default for Colour {
    fn default() -> Self {
        Colour::None
    }
}

pub enum Style {
    ASCII,
    Block,
    Balloon,
    Pacman,
    Custom(String),
}

impl Default for Style {
    fn default() -> Self {
        Style::Block
    }
}

impl std::fmt::Display for Style {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                Style::ASCII => "0123456789#",
                Style::Block => " ▏▎▍▌▋▊▉█",
                Style::Balloon => ".oO@*",
                Style::Pacman => "C-",
                Style::Custom(n) => &n[..],
            }
        )
    }
}