log_table/
color.rs

1use colored::*;
2
3#[derive(Clone, Copy)]
4pub enum Color {
5    Blue,
6    Green,
7    Red,
8    Orange,
9    White,
10    Gray,
11    Black,
12    Yellow,
13    Purple,
14}
15
16impl Color {
17    pub fn to_colored_string(&self, s: &str) -> String {
18        match self {
19            Color::Blue => s.blue().to_string(),
20            Color::Green => s.green().to_string(),
21            Color::Red => s.red().to_string(),
22            Color::Orange => s.truecolor(255, 165, 0).to_string(),
23            Color::White => s.white().to_string(),
24            Color::Gray => s.truecolor(128, 128, 128).to_string(),
25            Color::Black => s.black().to_string(),
26            Color::Yellow => s.yellow().to_string(),
27            Color::Purple => s.purple().to_string(),
28        }
29    }
30}