egui_cha_analyzer/
types.rs1#[derive(Debug, Clone, PartialEq)]
5pub struct UiElement {
6 pub element_type: String,
8 pub label: Option<String>,
10 pub context: String,
12 pub file_path: String,
14 pub line: usize,
16 pub response_var: Option<String>,
18}
19
20#[derive(Debug, Clone, PartialEq)]
22pub struct Action {
23 pub action_type: String,
25 pub source: String,
27 pub context: String,
29 pub file_path: String,
31 pub line: usize,
33}
34
35#[derive(Debug, Clone, PartialEq)]
37pub struct StateMutation {
38 pub target: String,
40 pub mutation_type: String,
42 pub context: String,
44 pub file_path: String,
46 pub line: usize,
48}
49
50#[derive(Debug, Clone)]
53pub struct UiFlow {
54 pub ui_element: UiElement,
55 pub action: Action,
56 pub state_mutations: Vec<StateMutation>,
57 pub context: String,
58}
59
60#[derive(Debug, Clone, PartialEq)]
66pub struct MsgEmission {
67 pub component: String,
69 pub variant: String,
71 pub label: Option<String>,
73 pub action: String,
75 pub msg: String,
77 pub context: String,
79 pub file_path: String,
81}
82
83#[derive(Debug, Clone, PartialEq)]
85pub struct MsgHandler {
86 pub msg_pattern: String,
88 pub state_mutations: Vec<StateMutation>,
90 pub file_path: String,
92}
93
94#[derive(Debug, Clone)]
96pub struct TeaFlow {
97 pub emission: MsgEmission,
98 pub handler: Option<MsgHandler>,
99}
100
101#[derive(Debug, Clone)]
103pub struct FileAnalysis {
104 pub path: String,
105 pub ui_elements: Vec<UiElement>,
106 pub actions: Vec<Action>,
107 pub state_mutations: Vec<StateMutation>,
108 pub flows: Vec<UiFlow>,
110 pub msg_emissions: Vec<MsgEmission>,
112 pub msg_handlers: Vec<MsgHandler>,
114 pub tea_flows: Vec<TeaFlow>,
116}
117
118impl FileAnalysis {
119 pub fn new(path: String) -> Self {
120 Self {
121 path,
122 ui_elements: Vec::new(),
123 actions: Vec::new(),
124 state_mutations: Vec::new(),
125 flows: Vec::new(),
126 msg_emissions: Vec::new(),
127 msg_handlers: Vec::new(),
128 tea_flows: Vec::new(),
129 }
130 }
131}
132
133#[derive(Debug, Clone, Default)]
135pub struct AnalysisResult {
136 pub files: Vec<FileAnalysis>,
137}
138
139impl AnalysisResult {
140 pub fn new() -> Self {
141 Self::default()
142 }
143
144 pub fn add_file(&mut self, analysis: FileAnalysis) {
145 self.files.push(analysis);
146 }
147
148 pub fn all_ui_elements(&self) -> impl Iterator<Item = &UiElement> {
149 self.files.iter().flat_map(|f| &f.ui_elements)
150 }
151
152 pub fn all_actions(&self) -> impl Iterator<Item = &Action> {
153 self.files.iter().flat_map(|f| &f.actions)
154 }
155
156 pub fn all_state_mutations(&self) -> impl Iterator<Item = &StateMutation> {
157 self.files.iter().flat_map(|f| &f.state_mutations)
158 }
159}