Skip to main content

ComponentMatcher

Trait ComponentMatcher 

Source
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§

Source

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§

Source

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.

Source

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.

Source

fn find_best_match<'a>( &self, target: &Component, candidates: &'a [&Component], threshold: f64, ) -> Option<(&'a Component, f64)>

Find the best matching component from a list of candidates.

Returns the best match and its score, or None if no match meets the threshold.

Source

fn name(&self) -> &'static str

Get the name of this matcher for logging/debugging.

Source

fn threshold(&self) -> f64

Get the minimum threshold this matcher uses for fuzzy matching.

Implementors§