pub trait ComponentMatcher: Send + Sync {
// Required method
fn match_score(&self, a: &Component, b: &Component) -> f64;
// Provided methods
fn match_detailed(&self, a: &Component, b: &Component) -> MatchResult { ... }
fn explain_match(&self, a: &Component, b: &Component) -> MatchExplanation { ... }
fn find_best_match<'a>(
&self,
target: &Component,
candidates: &'a [&Component],
threshold: f64,
) -> Option<(&'a Component, f64)> { ... }
fn name(&self) -> &'static str { ... }
fn threshold(&self) -> f64 { ... }
}Expand description
Trait for component matching strategies.
Implementors provide different strategies for determining if two components represent the same logical package across SBOMs.
§Example
ⓘ
use sbom_tools::matching::{ComponentMatcher, FuzzyMatcher, FuzzyMatchConfig};
let matcher = FuzzyMatcher::new(FuzzyMatchConfig::balanced());
let score = matcher.match_score(&component_a, &component_b);Required Methods§
Sourcefn match_score(&self, a: &Component, b: &Component) -> f64
fn match_score(&self, a: &Component, b: &Component) -> f64
Compute a match score between two components.
Returns a score between 0.0 (no match) and 1.0 (perfect match).
Provided Methods§
Sourcefn match_detailed(&self, a: &Component, b: &Component) -> MatchResult
fn match_detailed(&self, a: &Component, b: &Component) -> MatchResult
Compute a detailed match result between two components.
Returns a MatchResult with score, tier, and metadata.
Sourcefn explain_match(&self, a: &Component, b: &Component) -> MatchExplanation
fn explain_match(&self, a: &Component, b: &Component) -> MatchExplanation
Generate a human-readable explanation of why two components matched or didn’t.
Useful for debugging and auditing match decisions.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".