sentri_report/
formatter.rs1use super::Report;
4
5pub struct ReportFormatter;
7
8impl ReportFormatter {
9 pub fn to_json(report: &Report) -> serde_json::Result<String> {
11 serde_json::to_string_pretty(&report)
12 }
13
14 pub fn to_markdown(report: &Report) -> String {
16 format!(
17 "# {}\n\n**Generated:** {}\n**Program:** {}\n\n## Summary\n- Invariants Checked: {}\n- Violations: {}\n- Coverage: {}%\n",
18 report.title,
19 report.generated_at,
20 report.program,
21 report.invariants_checked,
22 report.violations_found,
23 report.coverage_percent
24 )
25 }
26
27 pub fn to_cli_table(report: &Report) -> String {
29 format!(
30 "┌─────────────────────────────────────────┐\n│ {} (Coverage: {}%) │\n├─────────────────────────────────────────┤\n│ Invariants: {} | Violations: {} │\n└─────────────────────────────────────────┘\n",
31 report.program, report.coverage_percent, report.invariants_checked, report.violations_found
32 )
33 }
34}