mod severity;
mod threat;
use crate::issue::Issue;
use std::time::Instant;
use core::fmt::{
Display,
Formatter,
Result as Format
};
pub use severity::Severity;
pub use threat::{
Threat,
Threaten
};
pub struct Problem {
pub chain: Vec<&'static str>,
pub at: Instant,
pub issue: Issue,
pub severity: Severity
}
impl Display for Problem {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Format {write!(
formatter,
"@ {}\n{:?}: {}{}",
self.chain.iter().rev().map(|node| *node).collect::<Vec<&'static str>>().join(" > "),
<&Severity as Into<&'static str>>::into(&self.severity),
self.issue.name,
if let Some(description) = &self.issue.description {format!("\n {}", description)} else {String::new()}
)}
}