pub struct Diff {
pub added: Vec<Component>,
pub removed: Vec<Component>,
pub changed: Vec<ComponentChange>,
pub edge_diffs: Vec<EdgeDiff>,
pub metadata_changed: Option<MetadataChange>,
pub old_total: usize,
pub new_total: usize,
pub unchanged: usize,
pub component_names: BTreeMap<ComponentId, String>,
}Expand description
the result of comparing two SBOMs.
contains lists of added, removed, and changed components, as well as dependency edge changes.
Fields§
§added: Vec<Component>components present in the new SBOM but not the old.
removed: Vec<Component>components present in the old SBOM but not the new.
changed: Vec<ComponentChange>components present in both with field-level changes.
edge_diffs: Vec<EdgeDiff>dependency edge changes between components.
metadata_changed: Option<MetadataChange>structured metadata change details, or None if metadata is unchanged.
old_total: usizetotal number of components in the old SBOM.
new_total: usizetotal number of components in the new SBOM.
unchanged: usizenumber of components present in both SBOMs with no changes.
component_names: BTreeMap<ComponentId, String>human-readable display names for component IDs that appear in edge diffs.
maps hash-based IDs (h:...) to name@version or name so that edge
diff output is readable without cross-referencing the full component list.
Implementations§
Source§impl Diff
impl Diff
Sourcepub fn display_name<'a>(&'a self, id: &'a ComponentId) -> &'a str
pub fn display_name<'a>(&'a self, id: &'a ComponentId) -> &'a str
returns a human-readable display name for a component ID.
looks up the ID in component_names; falls back to the raw ID string.
Sourcepub fn ecosystem_breakdown(&self) -> BTreeMap<String, EcosystemCounts>
pub fn ecosystem_breakdown(&self) -> BTreeMap<String, EcosystemCounts>
groups added/removed/changed counts by package ecosystem.
components without an ecosystem are grouped under "unknown".
Sourcepub fn group_by_ecosystem(&self) -> GroupedDiff
pub fn group_by_ecosystem(&self) -> GroupedDiff
groups the full diff by ecosystem, returning per-ecosystem slices.
components without an ecosystem are grouped under "unknown".
this clones components out of the diff; use
into_group_by_ecosystem to move
them instead when you own the diff.
Sourcepub fn into_group_by_ecosystem(self) -> GroupedDiff
pub fn into_group_by_ecosystem(self) -> GroupedDiff
consuming variant of group_by_ecosystem
that moves components instead of cloning them.
Sourcepub fn filter_by_ecosystem<F: Fn(Option<&str>) -> bool>(
&mut self,
matches: &F,
filtered_old_total: usize,
filtered_new_total: usize,
component_ecosystems: &BTreeMap<ComponentId, Option<String>>,
)
pub fn filter_by_ecosystem<F: Fn(Option<&str>) -> bool>( &mut self, matches: &F, filtered_old_total: usize, filtered_new_total: usize, component_ecosystems: &BTreeMap<ComponentId, Option<String>>, )
filters the diff to only include components whose ecosystem matches
the given predicate. Adjusts old_total, new_total, and unchanged
to reflect the filtered view.
filtered_old_total and filtered_new_total are the pre-counted
number of components in each SBOM that pass the predicate. These must
be computed before Differ::diff_owned consumes the SBOMs.
component_ecosystems maps component IDs to their ecosystem, built
from both SBOMs before they are consumed. This is used to filter
edge diffs by the parent component’s ecosystem.