quantrs2_circuit/formatter/
types.rs1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5use std::time::Duration;
6
7#[derive(Debug, Clone)]
9pub struct FormattingResult {
10 pub formatted_circuit: FormattedCircuit,
12 pub statistics: FormattingStatistics,
14 pub changes: Vec<FormattingChange>,
16 pub style_information: StyleInformation,
18 pub quality_metrics: QualityMetrics,
20 pub duration: Duration,
22}
23
24#[derive(Debug, Clone)]
26pub struct FormattedCircuit {
27 pub code: String,
29 pub line_count: usize,
31 pub char_count: usize,
33}
34
35#[derive(Debug, Clone, Default)]
37pub struct FormattingStatistics {
38 pub total_lines: usize,
40 pub lines_modified: usize,
42 pub characters_added: usize,
44 pub characters_removed: usize,
46 pub formatting_time: Duration,
48}
49
50#[derive(Debug, Clone)]
52pub struct FormattingChange {
53 pub change_type: ChangeType,
55 pub start: Position,
57 pub end: Position,
59 pub old_text: String,
61 pub new_text: String,
63}
64
65#[derive(Debug, Clone)]
67pub enum ChangeType {
68 Indentation,
69 Spacing,
70 LineBreak,
71 Alignment,
72 Comment,
73 Organization,
74}
75
76#[derive(Debug, Clone)]
78pub struct Position {
79 pub line: usize,
80 pub column: usize,
81}
82
83#[derive(Debug, Clone)]
85pub struct StyleInformation {
86 pub applied_rules: Vec<String>,
88 pub violations_fixed: Vec<String>,
90 pub compliance_score: f64,
92 pub consistency_metrics: ConsistencyMetrics,
94}
95
96#[derive(Debug, Clone)]
98pub struct ConsistencyMetrics {
99 pub naming_consistency: f64,
100 pub indentation_consistency: f64,
101 pub spacing_consistency: f64,
102 pub comment_consistency: f64,
103 pub overall_consistency: f64,
104}
105
106#[derive(Debug, Clone)]
108pub struct QualityMetrics {
109 pub readability_score: f64,
111 pub maintainability_score: f64,
113 pub complexity_score: f64,
115 pub overall_quality: f64,
117}
118
119#[derive(Debug, Clone)]
121pub struct StyleCompliance {
122 pub compliance_level: ComplianceLevel,
124 pub issues: Vec<StyleIssue>,
126 pub score: f64,
128}
129
130#[derive(Debug, Clone)]
132pub enum ComplianceLevel {
133 Excellent,
134 Good,
135 Fair,
136 Poor,
137}
138
139#[derive(Debug, Clone)]
141pub struct StyleIssue {
142 pub issue_type: String,
144 pub description: String,
146 pub severity: String,
148 pub location: Option<Position>,
150}
151
152#[derive(Debug, Clone, Default)]
154pub struct CodeStructure {
155 pub sections: Vec<CodeSection>,
157 pub dependencies: Vec<String>,
159}
160
161#[derive(Debug, Clone)]
163pub struct CodeSection {
164 pub name: String,
166 pub content: String,
168 pub start_line: usize,
170 pub end_line: usize,
172}
173
174#[derive(Debug, Clone)]
176pub struct WhitespaceStatistics {
177 pub total_whitespace: usize,
178 pub indentation_chars: usize,
179 pub spacing_chars: usize,
180 pub line_breaks: usize,
181 pub consistency_score: f64,
182}
183
184#[derive(Debug, Clone)]
186pub struct AlignmentStatistics {
187 pub total_alignments: usize,
188 pub successful_alignments: usize,
189 pub average_quality: f64,
190 pub consistency_score: f64,
191}
192
193#[derive(Debug, Clone)]
195pub struct WhitespaceState {
196 pub indentation_level: usize,
197 pub line_length: usize,
198 pub pending_changes: Vec<FormattingChange>,
199 pub statistics: WhitespaceStatistics,
200}
201
202#[derive(Debug, Clone)]
204pub struct AlignmentState {
205 pub active_alignments: Vec<AlignmentGroup>,
206 pub alignment_columns: Vec<usize>,
207 pub statistics: AlignmentStatistics,
208}
209
210#[derive(Debug, Clone)]
212pub struct AlignmentGroup {
213 pub items: Vec<AlignmentItem>,
214 pub column: usize,
215}
216
217#[derive(Debug, Clone)]
219pub struct AlignmentItem {
220 pub text: String,
221 pub position: Position,
222}
223
224#[derive(Debug, Clone)]
226pub struct WhitespaceOptimization {
227 pub remove_trailing: bool,
228 pub normalize_indentation: bool,
229 pub optimize_line_breaks: bool,
230 pub compress_empty_lines: bool,
231 pub target_compression: f64,
232}
233
234#[derive(Debug, Clone)]
236pub struct AlignmentOptimization {
237 pub auto_detect: bool,
238 pub quality_threshold: f64,
239 pub max_distance: usize,
240 pub prefer_compact: bool,
241}
242
243#[derive(Debug, Clone)]
245pub struct CommentFormatterState {
246 pub rules: Vec<CommentRule>,
247 pub templates: HashMap<String, String>,
248 pub quality_threshold: f64,
249}
250
251#[derive(Debug, Clone)]
253pub struct CommentRule {
254 pub name: String,
255 pub pattern: String,
256 pub replacement: String,
257}