1pub(super) use self::format::FormattedRuleViolation;
4use super::rules::RuleViolation;
5
6mod format;
7
8#[derive(Clone, Copy)]
9pub(super) enum ViolationOutputFormat {
10 Compact,
11 Debug,
12}
13
14pub struct RslOutput {
15 violations: Vec<Box<dyn RuleViolation>>,
16 format: ViolationOutputFormat,
17}
18
19impl RslOutput {
20 pub(super) const fn new(violations: Vec<Box<dyn RuleViolation>>, format: ViolationOutputFormat) -> Self {
21 Self { violations, format }
22 }
23
24 pub const fn is_empty(&self) -> bool {
25 self.violations.is_empty()
26 }
27
28 pub fn render(&self) -> String {
29 self.violations
30 .iter()
31 .map(|violation| violation.render(self.format))
32 .collect::<Vec<_>>()
33 .join("\n")
34 }
35}