pub trait ErrorKind: PartialEq + Default {
type Settings: Clone;
fn descriptor(&self) -> &'static str;
fn is_error(&self, settings: Self::Settings) -> bool;
fn ignored(&self, settings: Self::Settings) -> bool;
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum BasicKind {
#[default]
Error,
Warning,
}
impl ErrorKind for BasicKind {
type Settings = ();
fn descriptor(&self) -> &'static str {
match self {
Self::Error => "error",
Self::Warning => "warning",
}
}
fn is_error(&self, _settings: Self::Settings) -> bool {
matches!(self, Self::Error)
}
fn ignored(&self, _settings: Self::Settings) -> bool {
false
}
}
impl std::fmt::Display for BasicKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.descriptor())
}
}