solidhunter_lib/types/
severity.rs

1use colored::Colorize;
2use serde::{Deserialize, Serialize};
3use std::fmt;
4
5#[derive(PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Debug)]
6pub enum Severity {
7    /// Reports an error.
8    ERROR = 1,
9    /// Reports a warning.
10    WARNING = 2,
11    /// Reports an information.
12    INFO = 3,
13    /// Reports a hint.
14    HINT = 4,
15}
16
17impl fmt::Display for Severity {
18    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19        let severity = match self {
20            Severity::ERROR => "error".to_string().red(),
21            Severity::WARNING => "warning".to_string().yellow(),
22            Severity::INFO => "info".to_string().blue(),
23            Severity::HINT => "hint".to_string().green(),
24        };
25        write!(f, "{}", severity)
26    }
27}