dkp_core/validate/
gates.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4pub enum Gate {
5 Gate4 = 4,
7 Gate7 = 7,
9 Gate8 = 8,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14pub enum GateStatus {
15 Pass,
16 Fail,
17 Skipped,
19 NotApplicable,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct GateResult {
25 pub gate: u8,
26 pub status: GateStatus,
27 pub checks: Vec<CheckResult>,
28 #[serde(skip_serializing_if = "Option::is_none")]
29 pub message: Option<String>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct CheckResult {
34 pub description: String,
35 pub status: GateStatus,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 pub detail: Option<String>,
38}
39
40impl CheckResult {
41 pub fn pass(description: impl Into<String>) -> Self {
42 Self {
43 description: description.into(),
44 status: GateStatus::Pass,
45 detail: None,
46 }
47 }
48
49 pub fn fail(description: impl Into<String>, detail: impl Into<String>) -> Self {
50 Self {
51 description: description.into(),
52 status: GateStatus::Fail,
53 detail: Some(detail.into()),
54 }
55 }
56
57 pub fn skip(description: impl Into<String>) -> Self {
58 Self {
59 description: description.into(),
60 status: GateStatus::Skipped,
61 detail: None,
62 }
63 }
64}
65
66#[derive(Debug, Serialize, Deserialize)]
67pub struct ValidationReport {
68 pub pack_name: String,
69 pub pack_version: String,
70 pub gates: Vec<GateResult>,
71 pub overall: GateStatus,
72 pub conformance: ConformanceLevel,
73 pub reviewed: bool,
74}
75
76#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
77pub enum ConformanceLevel {
78 DkpConformant,
80 DkpReviewed,
82 NonConformant,
84}