1#[derive(Debug, Clone)]
7pub struct DebugInfo {
8 pub variables_accessed: Vec<String>,
10 pub templates_processed: Vec<String>,
12 pub execution_steps: Vec<ExecutionStep>,
14 pub performance_metrics: PerformanceMetrics,
16}
17
18#[derive(Debug, Clone)]
20pub struct ExecutionStep {
21 pub step_type: String,
23 pub content: String,
25 pub line: usize,
27 pub column: usize,
29 pub duration_nanos: u64,
31 pub result: Option<String>,
33}
34
35#[derive(Debug, Clone)]
37pub struct PerformanceMetrics {
38 pub total_time_nanos: u64,
40 pub variable_resolution_nanos: u64,
42 pub parsing_nanos: u64,
44 pub include_nanos: u64,
46 pub memory_usage_bytes: usize,
48}
49
50#[derive(Debug)]
52pub struct DebugRenderResult {
53 pub output: String,
55 pub debug_info: DebugInfo,
57}
58
59impl Default for DebugInfo {
60 fn default() -> Self {
61 Self::new()
62 }
63}
64
65impl DebugInfo {
66 pub fn new() -> Self {
68 Self {
69 variables_accessed: Vec::new(),
70 templates_processed: Vec::new(),
71 execution_steps: Vec::new(),
72 performance_metrics: PerformanceMetrics::new(),
73 }
74 }
75
76 pub fn add_variable_access(&mut self, variable: &str) {
78 if !self.variables_accessed.contains(&variable.to_string()) {
79 self.variables_accessed.push(variable.to_string());
80 }
81 }
82
83 pub fn add_template_processed(&mut self, template: &str) {
85 self.templates_processed.push(template.to_string());
86 }
87
88 pub fn add_execution_step(&mut self, step: ExecutionStep) {
90 self.execution_steps.push(step);
91 }
92}
93
94impl Default for PerformanceMetrics {
95 fn default() -> Self {
96 Self::new()
97 }
98}
99
100impl PerformanceMetrics {
101 pub fn new() -> Self {
103 Self {
104 total_time_nanos: 0,
105 variable_resolution_nanos: 0,
106 parsing_nanos: 0,
107 include_nanos: 0,
108 memory_usage_bytes: 0,
109 }
110 }
111}
112
113impl ExecutionStep {
114 pub fn new(step_type: &str, content: &str, line: usize, column: usize) -> Self {
116 Self {
117 step_type: step_type.to_string(),
118 content: content.to_string(),
119 line,
120 column,
121 duration_nanos: 0,
122 result: None,
123 }
124 }
125
126 pub fn with_result(mut self, result: String) -> Self {
128 self.result = Some(result);
129 self
130 }
131
132 pub fn with_duration(mut self, duration_nanos: u64) -> Self {
134 self.duration_nanos = duration_nanos;
135 self
136 }
137}