quantrs2_device/unified_benchmarking/
reporting.rs1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5use std::time::SystemTime;
6
7use super::config::ExportDestination;
8
9pub struct ReportGenerator {
11 report_templates: HashMap<String, ReportTemplate>,
12 export_handlers: HashMap<ExportDestination, Box<dyn ExportHandler + Send + Sync>>,
13 visualization_engine: VisualizationEngine,
14}
15
16pub trait ExportHandler {
17 fn export(&self, report: &GeneratedReport) -> Result<String, String>;
18}
19
20#[derive(Debug, Clone)]
21pub struct ReportTemplate {
22 pub template_id: String,
23 pub template_name: String,
24 pub sections: Vec<ReportSection>,
25 pub styling: ReportStyling,
26}
27
28#[derive(Debug, Clone)]
29pub struct ReportSection {
30 pub section_id: String,
31 pub title: String,
32 pub content_type: SectionContentType,
33 pub data_queries: Vec<DataQuery>,
34}
35
36#[derive(Debug, Clone, PartialEq, Eq)]
37pub enum SectionContentType {
38 Text,
39 Table,
40 Chart,
41 Statistical,
42 Comparison,
43 Custom(String),
44}
45
46#[derive(Debug, Clone)]
47pub struct DataQuery {
48 pub query_id: String,
49 pub query_type: QueryType,
50 pub filters: HashMap<String, String>,
51 pub aggregations: Vec<String>,
52}
53
54#[derive(Debug, Clone, PartialEq, Eq)]
55pub enum QueryType {
56 PerformanceMetrics,
57 CostAnalysis,
58 TrendAnalysis,
59 Comparison,
60 Statistical,
61}
62
63#[derive(Debug, Clone)]
64pub struct ReportStyling {
65 pub theme: String,
66 pub color_scheme: Vec<String>,
67 pub font_family: String,
68 pub custom_css: Option<String>,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct GeneratedReport {
73 pub report_id: String,
74 pub report_type: String,
75 pub generation_time: SystemTime,
76 pub content: ReportContent,
77 pub metadata: ReportMetadata,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct ReportContent {
82 pub sections: Vec<ReportSectionContent>,
83 pub attachments: Vec<ReportAttachment>,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
87pub struct ReportSectionContent {
88 pub section_id: String,
89 pub title: String,
90 pub content: String,
91 pub visualizations: Vec<VisualizationData>,
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
95pub struct ReportAttachment {
96 pub attachment_id: String,
97 pub filename: String,
98 pub content_type: String,
99 pub data: Vec<u8>,
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct ReportMetadata {
104 pub report_id: String,
105 pub title: String,
106 pub description: String,
107 pub author: String,
108 pub keywords: Vec<String>,
109 pub data_sources: Vec<String>,
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
113pub struct VisualizationData {
114 pub visualization_id: String,
115 pub visualization_type: String,
116 pub data: Vec<u8>,
117 pub format: String,
118}
119
120#[derive(Debug, Clone)]
121pub struct VisualizationEngine {
122 pub chart_library: String,
123 pub default_width: u32,
124 pub default_height: u32,
125 pub color_palette: Vec<String>,
126 pub font_size: f32,
127 pub marker_size: f32,
128}
129
130impl Default for ReportGenerator {
131 fn default() -> Self {
132 Self::new()
133 }
134}
135
136impl ReportGenerator {
137 pub fn new() -> Self {
138 Self {
139 report_templates: HashMap::new(),
140 export_handlers: HashMap::new(),
141 visualization_engine: VisualizationEngine {
142 chart_library: "plotters".to_string(),
143 default_width: 800,
144 default_height: 600,
145 color_palette: vec![
146 "#1f77b4".to_string(),
147 "#ff7f0e".to_string(),
148 "#2ca02c".to_string(),
149 "#d62728".to_string(),
150 ],
151 font_size: 12.0,
152 marker_size: 5.0,
153 },
154 }
155 }
156
157 }