winbrew_models\msi_inventory/
records.rs

1//! Normalized MSI inventory records persisted for repair and doctor flows.
2
3use serde::{Deserialize, Serialize};
4
5use crate::install::InstallScope;
6use crate::shared::HashAlgorithm;
7
8/// The MSI inventory receipt stored for a package.
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10pub struct MsiInventoryReceipt {
11    /// Package name.
12    pub package_name: String,
13    /// Product code reported by the MSI.
14    pub product_code: String,
15    /// Optional upgrade code reported by the MSI.
16    pub upgrade_code: Option<String>,
17    /// Install scope recorded for the package.
18    pub scope: InstallScope,
19}
20
21/// A normalized MSI file entry.
22#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
23pub struct MsiFileRecord {
24    /// Package name.
25    pub package_name: String,
26    /// Original file path.
27    pub path: String,
28    /// Lowercased normalized path used for lookups.
29    pub normalized_path: String,
30    /// Optional hash algorithm used for the file.
31    pub hash_algorithm: Option<HashAlgorithm>,
32    /// Hex hash string associated with the file.
33    pub hash_hex: Option<String>,
34    /// Whether the file originated from a config-related MSI entry.
35    pub is_config_file: bool,
36}
37
38/// A normalized MSI registry entry.
39#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
40pub struct MsiRegistryRecord {
41    /// Package name.
42    pub package_name: String,
43    /// Registry hive name.
44    pub hive: String,
45    /// Raw registry key path.
46    pub key_path: String,
47    /// Lowercased normalized key path used for lookups.
48    pub normalized_key_path: String,
49    /// Registry value name.
50    pub value_name: String,
51    /// Registry value data, when present.
52    pub value_data: Option<String>,
53    /// Previous value captured for repair comparison, when present.
54    pub previous_value: Option<String>,
55}
56
57/// A normalized MSI shortcut entry.
58#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
59pub struct MsiShortcutRecord {
60    /// Package name.
61    pub package_name: String,
62    /// Shortcut path.
63    pub path: String,
64    /// Lowercased normalized shortcut path.
65    pub normalized_path: String,
66    /// Shortcut target path, when present.
67    pub target_path: Option<String>,
68    /// Lowercased normalized target path, when present.
69    pub normalized_target_path: Option<String>,
70}
71
72/// A normalized MSI component entry.
73#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
74pub struct MsiComponentRecord {
75    /// Package name.
76    pub package_name: String,
77    /// MSI component identifier.
78    pub component_id: String,
79    /// Optional component path.
80    pub path: Option<String>,
81    /// Lowercased normalized component path, when present.
82    pub normalized_path: Option<String>,
83}
84
85/// The complete MSI inventory snapshot for a package.
86#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
87pub struct MsiInventorySnapshot {
88    /// Receipt metadata for the package.
89    pub receipt: MsiInventoryReceipt,
90    /// Normalized file rows.
91    pub files: Vec<MsiFileRecord>,
92    /// Normalized registry rows.
93    pub registry_entries: Vec<MsiRegistryRecord>,
94    /// Normalized shortcut rows.
95    pub shortcuts: Vec<MsiShortcutRecord>,
96    /// Normalized component rows.
97    pub components: Vec<MsiComponentRecord>,
98}