clnrm_core/reporting/
mod.rs1pub mod digest;
7pub mod json;
8pub mod junit;
9
10use crate::error::Result;
11use crate::validation::ValidationReport;
12use std::path::Path;
13
14pub use digest::DigestReporter;
15pub use json::JsonReporter;
16pub use junit::JunitReporter;
17
18#[derive(Debug, Clone, Default)]
20pub struct ReportConfig {
21 pub json_path: Option<String>,
23 pub junit_path: Option<String>,
25 pub digest_path: Option<String>,
27}
28
29impl ReportConfig {
30 pub fn new() -> Self {
32 Self::default()
33 }
34
35 pub fn with_json(mut self, path: impl Into<String>) -> Self {
37 self.json_path = Some(path.into());
38 self
39 }
40
41 pub fn with_junit(mut self, path: impl Into<String>) -> Self {
43 self.junit_path = Some(path.into());
44 self
45 }
46
47 pub fn with_digest(mut self, path: impl Into<String>) -> Self {
49 self.digest_path = Some(path.into());
50 self
51 }
52}
53
54pub fn generate_reports(
67 config: &ReportConfig,
68 report: &ValidationReport,
69 spans_json: &str,
70) -> Result<()> {
71 if let Some(ref json_path) = config.json_path {
72 JsonReporter::write(Path::new(json_path), report)?;
73 }
74
75 if let Some(ref junit_path) = config.junit_path {
76 JunitReporter::write(Path::new(junit_path), report)?;
77 }
78
79 if let Some(ref digest_path) = config.digest_path {
80 DigestReporter::write(Path::new(digest_path), spans_json)?;
81 }
82
83 Ok(())
84}