#[cfg(all(test, feature = "gpu", target_os = "linux"))]
pub(crate) use crate::gpu::load_dynamic_library;
#[cfg(all(feature = "gpu", target_os = "linux"))]
pub(crate) use crate::gpu::probe_cuda_peer;
pub use crate::gpu::GpuBackendAvailability;
pub(crate) use crate::gpu::{GpuBackendAcquisitionFailure, GpuBackendPeers, SelectedGpuPeer};
use crate::hw_probe::ScanBackend;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum GpuInitPolicy {
FromRuntimePolicy,
ForceEnabled,
SelectedBackend(ScanBackend),
ForceDisabled,
}
#[cfg(all(test, feature = "gpu", target_os = "linux"))]
#[path = "../../tests/unit/compiled_scanner_cuda_driver_preflight.rs"]
mod cuda_driver_preflight_tests;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct GpuBackendCandidateStatus {
pub backend: ScanBackend,
pub available: bool,
pub acquired: bool,
pub driver_id: Option<&'static str>,
pub driver_version: Option<&'static str>,
pub device_identity: Option<String>,
pub runtime_identity: Option<String>,
pub is_software: bool,
pub acquisition_error: Option<String>,
}
impl GpuBackendCandidateStatus {
#[must_use]
pub fn has_complete_identity(&self) -> bool {
self.driver_id.is_some_and(|value| !value.trim().is_empty())
&& self
.driver_version
.is_some_and(|value| !value.trim().is_empty())
&& self
.device_identity
.as_deref()
.is_some_and(|value| !value.trim().is_empty())
&& self
.runtime_identity
.as_deref()
.is_some_and(|value| !value.trim().is_empty())
}
#[must_use]
pub fn is_eligible(&self) -> bool {
self.available && !self.is_software && self.has_complete_identity()
}
#[must_use]
pub fn is_acquired_eligible(&self) -> bool {
self.acquired && self.is_eligible()
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CompiledScannerRuntime {
pub detector_count: usize,
pub pattern_count: usize,
pub detector_digest: u64,
pub compiled_plan_digest: [u8; 32],
pub preferred_backend: &'static str,
pub gpu_backends: GpuBackendAvailability,
pub gpu_degrade_count: u64,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CompiledEvidenceRelation<'a> {
pub name: &'a str,
pub regex: &'a str,
pub capture_group: Option<usize>,
pub within_lines: usize,
pub within_bytes: Option<usize>,
pub direction: keyhog_core::EvidenceDirection,
pub scope: keyhog_core::EvidenceScope,
pub requirement: keyhog_core::EvidenceRequirement,
pub value_relation: keyhog_core::EvidenceValueRelation,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CompiledDetectorEvidenceRelation<'a> {
pub detector_id: &'a str,
pub kind: keyhog_core::DetectorRelationKind,
pub within_lines: usize,
pub within_bytes: Option<usize>,
pub direction: keyhog_core::EvidenceDirection,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CompiledEvidencePlan<'a> {
pub detector_id: &'a str,
pub relations: Vec<CompiledEvidenceRelation<'a>>,
pub detector_relations: Vec<CompiledDetectorEvidenceRelation<'a>>,
}