1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::format::Format;
#[derive(Debug)]
pub struct Code {
pub language: Option<String>,
pub code: String,
}
#[derive(Debug)]
pub enum ReportEntry {
Text(String),
Code(Code),
List(Vec<ReportEntry>),
Concat(Vec<ReportEntry>),
}
#[derive(Debug)]
pub(crate) struct ReportSection<'a> {
pub(crate) title: &'a str,
pub(crate) entry: ReportEntry,
}
impl ReportEntry {}
#[derive(Debug)]
pub(crate) struct Report<'a> {
pub(crate) sections: Vec<ReportSection<'a>>,
}
impl<'a> Report<'a> {
pub fn format_as(&self, format: &mut impl Format) -> String {
let mut result = String::new();
for section in &self.sections {
result += &format.format_section(section.title);
result += &format.format_entry(§ion.entry);
result += "\n";
}
result
}
}