Skip to main content

shine_core/runtime/
inspection.rs

1use super::{AppCategory, AppFile, ShellCategory, ShellFile};
2use crate::install::AppEntry;
3use std::path::PathBuf;
4
5#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
6pub enum InspectionFileStatus {
7    NotInstalled,
8    UpToDate,
9    UpdateAvail,
10    GeneratorNotEvaluated,
11    GeneratorEvaluationFailed,
12    GeneratorTrustRequired,
13    Partial,
14    UserModified,
15    Missing,
16}
17
18#[derive(Clone, Debug, Eq, PartialEq)]
19pub enum InspectionChange {
20    ContentChanged,
21    SourceRelocated {
22        from: PathBuf,
23        to: PathBuf,
24    },
25    DestinationRelocated {
26        from: PathBuf,
27        to: PathBuf,
28    },
29    NewFile {
30        destination: PathBuf,
31    },
32    DeploymentChanged {
33        field: &'static str,
34        from: String,
35        to: String,
36    },
37    CommandEntryMissing {
38        path: PathBuf,
39    },
40    CommandEntryOutdated {
41        path: PathBuf,
42    },
43    ManifestEntryMissing {
44        target: String,
45    },
46}
47
48impl InspectionChange {
49    pub fn includes_content(changes: &[Self]) -> bool {
50        changes.contains(&Self::ContentChanged)
51    }
52}
53
54#[derive(Clone, Debug)]
55pub struct AppFileInspection {
56    pub category: AppCategory,
57    pub file: AppFile,
58    pub destination: Option<PathBuf>,
59    pub status: InspectionFileStatus,
60    pub manifest_entry: Option<AppEntry>,
61    pub desired_content: Option<Vec<u8>>,
62    pub current_content: Option<Vec<u8>>,
63    pub changes: Vec<InspectionChange>,
64    pub assessment_error: Option<String>,
65    pub assessment_diagnostic: Option<&'static str>,
66}
67
68#[derive(Clone, Debug)]
69pub struct ShellFileInspection {
70    pub category: ShellCategory,
71    pub file: ShellFile,
72    pub source_path: PathBuf,
73    pub installed_source_path: PathBuf,
74    pub rendered_path: PathBuf,
75    pub link_path: PathBuf,
76    pub link_target: Option<PathBuf>,
77    pub desired_content: Option<Vec<u8>>,
78    pub current_content: Option<Vec<u8>>,
79    pub status: InspectionFileStatus,
80    pub status_text: &'static str,
81    pub installed: bool,
82    pub link_conflict: bool,
83    pub changes: Vec<InspectionChange>,
84}
85
86#[derive(Clone, Debug, Default)]
87pub struct DomainInspectionReport {
88    pub app_files: Vec<AppFileInspection>,
89    pub shell_files: Vec<ShellFileInspection>,
90}