1use super::contract::{LintCommitReceipt, LintDigest};
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
6#[serde(rename_all = "snake_case")]
7pub enum LintCapabilityContext {
8 DaemonOperatorEndpointUnauthenticatedUnverified,
9}
10impl LintCapabilityContext {
11 pub const fn daemon_operator_endpoint() -> Self {
12 Self::DaemonOperatorEndpointUnauthenticatedUnverified
13 }
14}
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
16#[serde(rename_all = "snake_case")]
17pub enum LintDbSnapshotMode {
18 TransactionalReadOnly,
19}
20#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
21#[serde(rename_all = "snake_case")]
22pub enum LintPageSnapshotMode {
23 BestEffort,
24}
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub struct LintDbSnapshotReceipt {
27 mode: LintDbSnapshotMode,
28 analysis_digest: LintDigest,
29 post_run_digest: Option<LintDigest>,
30}
31impl LintDbSnapshotReceipt {
32 pub fn new(
33 mode: LintDbSnapshotMode,
34 analysis_digest: LintDigest,
35 post_run_digest: Option<LintDigest>,
36 ) -> Self {
37 Self {
38 mode,
39 analysis_digest,
40 post_run_digest,
41 }
42 }
43 pub const fn mode(&self) -> LintDbSnapshotMode {
44 self.mode
45 }
46 pub fn analysis_digest(&self) -> &LintDigest {
47 &self.analysis_digest
48 }
49 pub fn post_run_digest(&self) -> Option<&LintDigest> {
50 self.post_run_digest.as_ref()
51 }
52}
53#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
54pub struct LintPageSnapshotReceipt {
55 mode: LintPageSnapshotMode,
56 before_scan_digest: LintDigest,
57 after_scan_digest: Option<LintDigest>,
58}
59impl LintPageSnapshotReceipt {
60 pub fn new(
61 mode: LintPageSnapshotMode,
62 before_scan_digest: LintDigest,
63 after_scan_digest: Option<LintDigest>,
64 ) -> Self {
65 Self {
66 mode,
67 before_scan_digest,
68 after_scan_digest,
69 }
70 }
71 pub const fn mode(&self) -> LintPageSnapshotMode {
72 self.mode
73 }
74 pub fn before_scan_digest(&self) -> &LintDigest {
75 &self.before_scan_digest
76 }
77 pub fn after_scan_digest(&self) -> Option<&LintDigest> {
78 self.after_scan_digest.as_ref()
79 }
80}
81#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
82pub struct LintSnapshotReceipts {
83 db: LintDbSnapshotReceipt,
84 pages: LintPageSnapshotReceipt,
85}
86impl LintSnapshotReceipts {
87 pub fn new(db: LintDbSnapshotReceipt, pages: LintPageSnapshotReceipt) -> Self {
88 Self { db, pages }
89 }
90 pub fn db(&self) -> &LintDbSnapshotReceipt {
91 &self.db
92 }
93 pub fn pages(&self) -> &LintPageSnapshotReceipt {
94 &self.pages
95 }
96}
97#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
98pub struct LintProducerReceipt {
99 runtime_commit: Option<LintCommitReceipt>,
100}
101impl LintProducerReceipt {
102 pub fn new(runtime_commit: Option<LintCommitReceipt>) -> Self {
103 Self { runtime_commit }
104 }
105 pub fn runtime_commit(&self) -> Option<&LintCommitReceipt> {
106 self.runtime_commit.as_ref()
107 }
108}
109
110#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
111#[serde(rename_all = "snake_case")]
112pub enum LintOutcome {
113 Pass,
114 Finding,
115 NotRunPrerequisite,
116 InconsistentSnapshot,
117 FailedToRun,
118}
119impl LintOutcome {
120 pub(crate) const fn is_complete(self) -> bool {
121 match self {
122 Self::Pass | Self::Finding => true,
123 Self::NotRunPrerequisite | Self::InconsistentSnapshot | Self::FailedToRun => false,
124 }
125 }
126}
127#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
128#[serde(rename_all = "snake_case")]
129pub enum LintGateEffect {
130 #[default]
131 Actionable,
132 Advisory,
133}
134#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
135#[serde(rename_all = "snake_case")]
136pub enum LintSeverity {
137 Info,
138 Warning,
139 Error,
140}
141#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
142#[serde(rename_all = "snake_case")]
143pub enum LintApplicability {
144 Applicable,
145 Inventory,
146 ExpectedEmpty,
147 NotApplicable,
148}
149#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
150#[serde(rename_all = "snake_case")]
151pub enum LintPrecondition {
152 Ready,
153 ExpectedEmpty,
154 ConfiguredOff,
155 MissingPrerequisite,
156 SnapshotUnstable,
157}