use crate::enrichment::EnrichmentStats;
use crate::error::Result;
use crate::model::Component;
pub trait VulnerabilityEnricher: Send + Sync {
fn enrich(&self, components: &mut [Component]) -> Result<EnrichmentStats>;
fn name(&self) -> &'static str;
fn is_available(&self) -> bool;
}
#[derive(Debug, Clone, Copy, Default)]
pub struct NoOpEnricher;
impl NoOpEnricher {
#[must_use]
pub const fn new() -> Self {
Self
}
}
impl VulnerabilityEnricher for NoOpEnricher {
fn enrich(&self, _components: &mut [Component]) -> Result<EnrichmentStats> {
Ok(EnrichmentStats::empty())
}
fn name(&self) -> &'static str {
"NoOp"
}
fn is_available(&self) -> bool {
false
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_noop_enricher_creation() {
let enricher = NoOpEnricher::new();
assert_eq!(enricher.name(), "NoOp");
assert!(!enricher.is_available());
}
#[test]
fn test_noop_enricher_does_nothing() {
let enricher = NoOpEnricher;
let mut components = vec![];
let stats = enricher.enrich(&mut components).unwrap();
assert_eq!(stats.components_checked(), 0);
}
#[test]
fn test_noop_enricher_default() {
let enricher = NoOpEnricher;
assert!(!enricher.is_available());
}
}