pub struct NormalizedSbomIndex { /* private fields */ }Expand description
Precomputed index for efficient SBOM queries.
This index is built once per SBOM and provides O(1) lookups for:
- Dependencies of a component (edges by source)
- Dependents of a component (edges by target)
- Components by lowercased name
- Pre-computed sort keys to avoid repeated string allocations
Implementations§
Source§impl NormalizedSbomIndex
impl NormalizedSbomIndex
Sourcepub fn build(sbom: &NormalizedSbom) -> Self
pub fn build(sbom: &NormalizedSbom) -> Self
Build an index from a normalized SBOM.
This is an O(n + m) operation where n = components and m = edges. The resulting index provides O(1) lookups.
Sourcepub fn dependency_indices(&self, id: &CanonicalId) -> &[usize]
pub fn dependency_indices(&self, id: &CanonicalId) -> &[usize]
Get edge indices for dependencies of a component (outgoing edges).
Returns empty slice if component has no dependencies. O(1) lookup instead of O(edges).
Sourcepub fn dependent_indices(&self, id: &CanonicalId) -> &[usize]
pub fn dependent_indices(&self, id: &CanonicalId) -> &[usize]
Get edge indices for dependents of a component (incoming edges).
Returns empty slice if component has no dependents. O(1) lookup instead of O(edges).
Sourcepub fn dependencies_of<'a>(
&self,
id: &CanonicalId,
edges: &'a [DependencyEdge],
) -> Vec<&'a DependencyEdge>
pub fn dependencies_of<'a>( &self, id: &CanonicalId, edges: &'a [DependencyEdge], ) -> Vec<&'a DependencyEdge>
Get dependencies of a component as edges.
O(k) where k = number of dependencies (much faster than O(edges)).
Sourcepub fn dependents_of<'a>(
&self,
id: &CanonicalId,
edges: &'a [DependencyEdge],
) -> Vec<&'a DependencyEdge>
pub fn dependents_of<'a>( &self, id: &CanonicalId, edges: &'a [DependencyEdge], ) -> Vec<&'a DependencyEdge>
Get dependents of a component as edges.
O(k) where k = number of dependents (much faster than O(edges)).
Sourcepub fn find_by_name_lower(&self, name_lower: &str) -> &[CanonicalId]
pub fn find_by_name_lower(&self, name_lower: &str) -> &[CanonicalId]
Find component IDs by lowercased name.
O(1) lookup instead of O(components).
Sourcepub fn search_by_name(&self, query_lower: &str) -> Vec<CanonicalId>
pub fn search_by_name(&self, query_lower: &str) -> Vec<CanonicalId>
Find component IDs whose name contains the query (case-insensitive).
O(unique_names) - still iterates but only over unique lowercased names,
not all components.
Sourcepub fn sort_key(&self, id: &CanonicalId) -> Option<&ComponentSortKey>
pub fn sort_key(&self, id: &CanonicalId) -> Option<&ComponentSortKey>
Get the pre-computed sort key for a component.
O(1) lookup, avoids repeated to_lowercase() calls during sorting.
Sourcepub const fn sort_keys(&self) -> &HashMap<CanonicalId, ComponentSortKey>
pub const fn sort_keys(&self) -> &HashMap<CanonicalId, ComponentSortKey>
Get all sort keys for iteration.
Sourcepub fn has_dependencies(&self, id: &CanonicalId) -> bool
pub fn has_dependencies(&self, id: &CanonicalId) -> bool
Check if component has any dependencies.
Sourcepub fn has_dependents(&self, id: &CanonicalId) -> bool
pub fn has_dependents(&self, id: &CanonicalId) -> bool
Check if component has any dependents.
Sourcepub fn dependency_count(&self, id: &CanonicalId) -> usize
pub fn dependency_count(&self, id: &CanonicalId) -> usize
Get count of dependencies for a component.
Sourcepub fn dependent_count(&self, id: &CanonicalId) -> usize
pub fn dependent_count(&self, id: &CanonicalId) -> usize
Get count of dependents for a component.
Sourcepub const fn component_count(&self) -> usize
pub const fn component_count(&self) -> usize
Get total component count.
Sourcepub const fn edge_count(&self) -> usize
pub const fn edge_count(&self) -> usize
Get total edge count.
Sourcepub fn root_count(&self) -> usize
pub fn root_count(&self) -> usize
Get count of root components (no incoming edges).
Sourcepub fn leaf_count(&self) -> usize
pub fn leaf_count(&self) -> usize
Get count of leaf components (no outgoing edges).
Trait Implementations§
Source§impl Clone for NormalizedSbomIndex
impl Clone for NormalizedSbomIndex
Source§fn clone(&self) -> NormalizedSbomIndex
fn clone(&self) -> NormalizedSbomIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NormalizedSbomIndex
impl RefUnwindSafe for NormalizedSbomIndex
impl Send for NormalizedSbomIndex
impl Sync for NormalizedSbomIndex
impl Unpin for NormalizedSbomIndex
impl UnsafeUnpin for NormalizedSbomIndex
impl UnwindSafe for NormalizedSbomIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more