1#![feature(const_trait_impl)]
7#![feature(const_convert)]
8
9mod severity;
11#[cfg(test)]
12mod tests;
13mod threat;
14
15use std::time::Instant;
17
18use core::fmt::{
20 Display,
21 Formatter,
22 Result as Format
23};
24
25pub use severity::Severity;
27
28pub use threat::{
30 Threat,
31 Threaten
32};
33
34use libutils_issue::Issue;
36
37
38pub struct Problem {
44 pub chain: Vec<&'static str>,
45 pub at: Instant,
46 pub issue: Issue,
47 pub severity: Severity
48}
49
50impl Display for Problem {
52 fn fmt(&self, formatter: &mut Formatter<'_>) -> Format {write!(
53 formatter,
54 "@ {}\n{:?}: {}{}",
55 self.chain.iter().rev().map(|node| *node).collect::<Vec<&'static str>>().join(" > "),
56 <&Severity as Into<&'static str>>::into(&self.severity),
57 self.issue.name,
58 if let Some(description) = &self.issue.description {format!("\n {}", description)} else {String::new()}
59 )}
60}