Skip to main content

disk_forensic/
report.rs

1//! Human-readable text rendering of a [`DiskReport`].
2//!
3//! Each scheme already has a renderer in its own crate; this delegates to the
4//! right one so the unified CLI prints a scheme-appropriate report.
5
6use crate::DiskReport;
7
8/// Render a disk analysis as a multi-line text report, showing the full detail
9/// from each scheme's own parser.
10#[must_use]
11pub fn text_report(report: &DiskReport) -> String {
12    match report {
13        DiskReport::Apm(a) => apm_forensic::report::text_report(a),
14        DiskReport::Mbr(m) => mbr_forensic::report::text_report(m),
15        // For GPT, show the protective-MBR analysis followed by the full GPT
16        // report (partitions, GUIDs, CRC status) from gpt-forensic.
17        DiskReport::Gpt(m) => {
18            let mut s = mbr_forensic::report::text_report(m);
19            if let Some(gpt) = &m.gpt {
20                s.push('\n');
21                s.push_str(&gpt_forensic::report::text_report(gpt));
22            }
23            s
24        }
25    }
26}