pcf_debug/render/mod.rs
1//! Rendering: turn the shared [`Report`] into text, hexdumps, or HTML. Both the
2//! text and HTML renderers consume the same model so they never diverge.
3
4pub mod color;
5pub mod hexdump;
6pub mod html;
7pub mod text;
8
9use crate::model::LayoutMap;
10use crate::plugin::Decoded;
11
12/// The shared input to every renderer: the physical layout plus the per-
13/// partition decoded field trees (paired with the partition UID).
14pub struct Report {
15 pub layout: LayoutMap,
16 pub decoded: Vec<([u8; 16], Decoded)>,
17}
18
19/// Format a 16-byte UID as lowercase hex.
20pub fn uid_hex(uid: &[u8; 16]) -> String {
21 uid.iter().map(|b| format!("{b:02x}")).collect()
22}
23
24/// Format a label, falling back to a placeholder for unreadable labels.
25pub fn label_or(entry: &pcf::PartitionEntry) -> String {
26 entry.label_string().unwrap_or_else(|_| "<invalid>".into())
27}