Skip to main content

canic_host/deployment_truth/model/artifact/
mod.rs

1use super::inventory::DeploymentObservationGapV1;
2use serde::{Deserialize, Serialize};
3
4///
5/// RoleArtifactManifestV1
6///
7#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
8pub struct RoleArtifactManifestV1 {
9    pub schema_version: u32,
10    pub manifest_id: String,
11    pub network: String,
12    pub artifact_root: Option<String>,
13    pub role_artifacts: Vec<RoleArtifactV1>,
14    pub unresolved_artifacts: Vec<DeploymentObservationGapV1>,
15}
16
17///
18/// RoleArtifactV1
19///
20#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
21pub struct RoleArtifactV1 {
22    pub role: String,
23    pub source: ArtifactSourceV1,
24    pub build_profile: String,
25    pub wasm_path: Option<String>,
26    pub wasm_gz_path: Option<String>,
27    pub wasm_gz_size_bytes: Option<u64>,
28    pub wasm_sha256: Option<String>,
29    pub wasm_gz_sha256: Option<String>,
30    pub wasm_gz_sha256_source: Option<ArtifactDigestSourceV1>,
31    pub observed_wasm_gz_file_sha256: Option<String>,
32    pub observed_wasm_gz_file_sha256_source: Option<ArtifactDigestSourceV1>,
33    pub installed_module_hash: Option<String>,
34    pub candid_path: Option<String>,
35    pub candid_sha256: Option<String>,
36    pub raw_config_sha256: Option<String>,
37    pub canonical_embedded_config_sha256: Option<String>,
38    pub embedded_topology_sha256: Option<String>,
39    pub builder_version: Option<String>,
40    pub rust_toolchain: Option<String>,
41    pub package_version: Option<String>,
42}
43
44///
45/// ArtifactDigestSourceV1
46///
47#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
48pub enum ArtifactDigestSourceV1 {
49    ReleaseSetManifest,
50    ObservedFileDigest,
51}
52
53///
54/// ArtifactSourceV1
55///
56#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
57pub enum ArtifactSourceV1 {
58    LocalBuild,
59    ReleaseSet,
60    WasmStore,
61    External,
62    Unknown,
63}
64
65impl ArtifactSourceV1 {
66    #[must_use]
67    pub const fn label(self) -> &'static str {
68        match self {
69            Self::LocalBuild => "LocalBuild",
70            Self::ReleaseSet => "ReleaseSet",
71            Self::WasmStore => "WasmStore",
72            Self::External => "External",
73            Self::Unknown => "Unknown",
74        }
75    }
76}
77
78///
79/// ObservedArtifactV1
80///
81#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
82pub struct ObservedArtifactV1 {
83    pub role: String,
84    pub artifact_path: String,
85    pub file_sha256: Option<String>,
86    pub file_sha256_source: Option<ArtifactDigestSourceV1>,
87    pub payload_sha256: Option<String>,
88    pub payload_size_bytes: Option<u64>,
89    pub source: ArtifactSourceV1,
90}
91
92#[cfg(test)]
93mod tests {
94    use super::*;
95
96    #[test]
97    fn artifact_source_owns_text_labels() {
98        assert_eq!(ArtifactSourceV1::LocalBuild.label(), "LocalBuild");
99        assert_eq!(ArtifactSourceV1::ReleaseSet.label(), "ReleaseSet");
100        assert_eq!(ArtifactSourceV1::WasmStore.label(), "WasmStore");
101        assert_eq!(ArtifactSourceV1::External.label(), "External");
102        assert_eq!(ArtifactSourceV1::Unknown.label(), "Unknown");
103    }
104}