keyhog_core/
compiled_artifact.rs1use serde::{Deserialize, Serialize};
8use std::fmt;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
12#[serde(rename_all = "kebab-case")]
13pub enum CompiledArtifactClass {
14 GpuLiteralSet,
16 Phase2GpuDfaCatalog,
18 HyperscanDatabase,
20 DetectorPlan,
22 ExecutionPack,
24 MatcherArtifact,
26}
27
28impl CompiledArtifactClass {
29 pub const ALL: &'static [CompiledArtifactClass] = &[
31 CompiledArtifactClass::GpuLiteralSet,
32 CompiledArtifactClass::Phase2GpuDfaCatalog,
33 CompiledArtifactClass::HyperscanDatabase,
34 CompiledArtifactClass::DetectorPlan,
35 CompiledArtifactClass::ExecutionPack,
36 CompiledArtifactClass::MatcherArtifact,
37 ];
38
39 pub const fn label(self) -> &'static str {
41 match self {
42 Self::GpuLiteralSet => "gpu-literal-set",
43 Self::Phase2GpuDfaCatalog => "phase2-gpu-dfa-catalog",
44 Self::HyperscanDatabase => "hyperscan-database",
45 Self::DetectorPlan => "detector-plan",
46 Self::ExecutionPack => "execution-pack",
47 Self::MatcherArtifact => "matcher-artifact",
48 }
49 }
50
51 pub const fn compile_owner(self) -> &'static str {
53 match self {
54 Self::GpuLiteralSet => "keyhog-scanner::gpu_literal_artifacts",
55 Self::Phase2GpuDfaCatalog => "keyhog-scanner::engine::phase2_gpu_dfa",
56 Self::HyperscanDatabase => "keyhog-scanner::simd::backend",
57 Self::DetectorPlan => "keyhog-scanner::compiled_scanner",
58 Self::ExecutionPack => "keyhog-scanner::execution_pack",
59 Self::MatcherArtifact => "keyhog-scanner::matcher_artifact_cache",
60 }
61 }
62}
63
64impl fmt::Display for CompiledArtifactClass {
65 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
66 write!(f, "{}", self.label())
67 }
68}
69
70#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
75pub struct CompiledArtifactIdentity {
76 pub artifact_class: CompiledArtifactClass,
78 pub binary_digest: String,
80 pub detector_digest: String,
82 pub config_digest: String,
84 pub platform: String,
86 pub adapter_identity: Option<String>,
88}