Skip to main content

cmtraceopen_parser/collector/
types.rs

1use serde::{Deserialize, Serialize};
2
3// ---------------------------------------------------------------------------
4// Collection profile types (deserialized from embedded JSON)
5// ---------------------------------------------------------------------------
6
7#[derive(Debug, Clone, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct CollectionProfile {
10    pub profile_name: String,
11    pub profile_version: String,
12    pub logs: Vec<LogCollectionItem>,
13    pub registry: Vec<RegistryCollectionItem>,
14    pub event_logs: Vec<EventLogCollectionItem>,
15    pub exports: Vec<FileExportItem>,
16    pub commands: Vec<CommandCollectionItem>,
17}
18
19#[derive(Debug, Clone, Deserialize)]
20#[serde(rename_all = "camelCase")]
21pub struct LogCollectionItem {
22    pub id: String,
23    pub family: String,
24    #[serde(default)]
25    pub parse_hints: Vec<String>,
26    pub source_pattern: String,
27    pub destination_folder: String,
28    pub notes: String,
29}
30
31#[derive(Debug, Clone, Deserialize)]
32#[serde(rename_all = "camelCase")]
33pub struct RegistryCollectionItem {
34    pub id: String,
35    pub family: String,
36    #[serde(default)]
37    pub parse_hints: Vec<String>,
38    pub path: String,
39    pub file_name: String,
40    pub notes: String,
41}
42
43#[derive(Debug, Clone, Deserialize)]
44#[serde(rename_all = "camelCase")]
45pub struct EventLogCollectionItem {
46    pub id: String,
47    pub family: String,
48    #[serde(default)]
49    pub parse_hints: Vec<String>,
50    pub source_pattern: String,
51    pub destination_folder: String,
52    pub notes: String,
53}
54
55#[derive(Debug, Clone, Deserialize)]
56#[serde(rename_all = "camelCase")]
57pub struct FileExportItem {
58    pub id: String,
59    pub family: String,
60    #[serde(default)]
61    pub parse_hints: Vec<String>,
62    pub source_path: String,
63    pub destination_folder: String,
64    pub file_name: Option<String>,
65    pub notes: String,
66}
67
68#[derive(Debug, Clone, Deserialize)]
69#[serde(rename_all = "camelCase")]
70pub struct CommandCollectionItem {
71    pub id: String,
72    pub family: String,
73    #[serde(default)]
74    pub parse_hints: Vec<String>,
75    pub command: String,
76    pub arguments: Vec<String>,
77    pub file_name: String,
78    pub timeout_secs: Option<u64>,
79    pub notes: String,
80}
81
82// ---------------------------------------------------------------------------
83// Result types (returned to frontend)
84// ---------------------------------------------------------------------------
85
86#[derive(Debug, Clone, Serialize)]
87#[serde(rename_all = "camelCase")]
88pub struct CollectionResult {
89    pub bundle_path: String,
90    pub bundle_id: String,
91    pub artifact_counts: ArtifactCounts,
92    pub duration_ms: u64,
93    pub gaps: Vec<CollectionGap>,
94}
95
96#[derive(Debug, Clone, Serialize)]
97#[serde(rename_all = "camelCase")]
98pub struct ArtifactCounts {
99    pub collected: u32,
100    pub missing: u32,
101    pub failed: u32,
102    pub total: u32,
103}
104
105#[derive(Debug, Clone, Serialize)]
106#[serde(rename_all = "camelCase")]
107pub struct CollectionGap {
108    pub artifact_id: String,
109    pub category: String,
110    pub reason: String,
111}
112
113// ---------------------------------------------------------------------------
114// Progress event payload (emitted to frontend via Tauri events)
115// ---------------------------------------------------------------------------
116
117#[derive(Debug, Clone, Serialize)]
118#[serde(rename_all = "camelCase")]
119pub struct CollectionProgressPayload {
120    pub request_id: String,
121    pub message: String,
122    pub current_item: Option<String>,
123    pub completed_items: usize,
124    pub total_items: usize,
125}
126
127// ---------------------------------------------------------------------------
128// Per-artifact result (thread-safe aggregation)
129// ---------------------------------------------------------------------------
130
131#[derive(Debug, Clone, Serialize)]
132#[serde(rename_all = "camelCase")]
133pub struct CollectedArtifactFile {
134    pub relative_path: String,
135    pub origin_path: Option<String>,
136    pub bytes_copied: u64,
137}
138
139#[derive(Debug, Clone, Serialize)]
140#[serde(rename_all = "camelCase")]
141pub struct ArtifactResult {
142    pub id: String,
143    pub category: String,
144    pub family: String,
145    pub parse_hints: Vec<String>,
146    pub notes: Option<String>,
147    pub status: ArtifactStatus,
148    pub files: Vec<CollectedArtifactFile>,
149    pub error: Option<String>,
150}
151
152#[derive(Debug, Clone, Serialize)]
153#[serde(rename_all = "camelCase")]
154pub enum ArtifactStatus {
155    Collected,
156    Missing,
157    Failed,
158}