Skip to main content

Diff

Struct Diff 

Source
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: usize

total number of components in the old SBOM.

§new_total: usize

total number of components in the new SBOM.

§unchanged: usize

number 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

Source

pub fn is_empty(&self) -> bool

returns true if the diff contains no changes of any kind.

Source

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.

Source

pub fn ecosystem_breakdown(&self) -> BTreeMap<String, EcosystemCounts>

groups added/removed/changed counts by package ecosystem.

components without an ecosystem are grouped under "unknown".

Source

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.

Source

pub fn into_group_by_ecosystem(self) -> GroupedDiff

consuming variant of group_by_ecosystem that moves components instead of cloning them.

Source

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.

Trait Implementations§

Source§

impl Clone for Diff

Source§

fn clone(&self) -> Diff

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diff

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Diff

Source§

fn default() -> Diff

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Diff

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Diff

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Diff

§

impl RefUnwindSafe for Diff

§

impl Send for Diff

§

impl Sync for Diff

§

impl Unpin for Diff

§

impl UnsafeUnpin for Diff

§

impl UnwindSafe for Diff

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.