Skip to main content

sbom_tools/diff/
engine_config.rs

1//! Configuration types for the diff engine.
2
3use crate::matching::CrossEcosystemConfig;
4
5/// Configuration for large SBOM optimization.
6#[derive(Debug, Clone)]
7pub struct LargeSbomConfig {
8    /// Minimum component count to enable LSH-based matching
9    pub lsh_threshold: usize,
10    /// Cross-ecosystem matching configuration
11    pub cross_ecosystem: CrossEcosystemConfig,
12    /// Maximum candidates per component
13    pub max_candidates: usize,
14}
15
16impl Default for LargeSbomConfig {
17    fn default() -> Self {
18        Self {
19            lsh_threshold: 500,
20            cross_ecosystem: CrossEcosystemConfig::default(),
21            max_candidates: 100,
22        }
23    }
24}
25
26impl LargeSbomConfig {
27    /// Check if cross-ecosystem matching is enabled.
28    #[must_use]
29    pub const fn enable_cross_ecosystem(&self) -> bool {
30        self.cross_ecosystem.enabled
31    }
32
33    /// Aggressive optimization for very large SBOMs (1000+)
34    #[must_use]
35    pub fn aggressive() -> Self {
36        Self {
37            lsh_threshold: 300,
38            cross_ecosystem: CrossEcosystemConfig::default(),
39            max_candidates: 50,
40        }
41    }
42
43    /// Conservative settings (for accuracy over speed)
44    #[must_use]
45    pub fn conservative() -> Self {
46        Self {
47            lsh_threshold: 1000,
48            cross_ecosystem: CrossEcosystemConfig::disabled(),
49            max_candidates: 150,
50        }
51    }
52}