pub mod code;
pub mod concerns;
pub mod lint;
pub mod parse;
pub mod validation;
pub use code::Code;
pub use concerns::Concerns;
use serde::Deserialize;
use serde::Serialize;
#[derive(Clone, Debug, Deserialize, Hash, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub enum Concern {
LintWarning(lint::Warning),
ParseError(parse::Error),
ValidationFailure(validation::Failure),
}
impl Concern {
pub fn as_lint_warning(&self) -> Option<&lint::Warning> {
match self {
Concern::LintWarning(warning) => Some(warning),
_ => None,
}
}
pub fn into_lint_warning(self) -> Option<lint::Warning> {
match self {
Concern::LintWarning(warning) => Some(warning),
_ => None,
}
}
pub fn as_validation_failure(&self) -> Option<&validation::Failure> {
match self {
Concern::ValidationFailure(failure) => Some(failure),
_ => None,
}
}
pub fn into_validation_failure(self) -> Option<validation::Failure> {
match self {
Concern::ValidationFailure(failure) => Some(failure),
_ => None,
}
}
pub fn as_parse_error(&self) -> Option<&parse::Error> {
match self {
Concern::ParseError(error) => Some(error),
_ => None,
}
}
pub fn into_parse_error(self) -> Option<parse::Error> {
match self {
Concern::ParseError(error) => Some(error),
_ => None,
}
}
}
impl std::fmt::Display for Concern {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Concern::LintWarning(warning) => write!(f, "{warning}"),
Concern::ParseError(error) => write!(f, "{error}"),
Concern::ValidationFailure(failure) => write!(f, "{failure}"),
}
}
}