pub struct Graph<'a> {
nodes: Vec<Node>,
edges: Vec<Edges>,
index: HashMap<Node, usize>,
package_map: HashMap<PackageId, &'a Package>,
cli_features: HashSet<usize>,
dep_name_map: HashMap<usize, HashMap<InternedString, HashSet<(usize, bool)>>>,
}
Expand description
A graph of dependencies.
Fields§
§nodes: Vec<Node>
§edges: Vec<Edges>
The indexes of edges
correspond to the nodes
. That is, edges[0]
is the set of outgoing edges for nodes[0]
. They should always be in
sync.
index: HashMap<Node, usize>
Index maps a node to an index, for fast lookup.
package_map: HashMap<PackageId, &'a Package>
Map for looking up packages.
cli_features: HashSet<usize>
Set of indexes of feature nodes that were added via the command-line.
For example --features foo
will mark the “foo” node here.
dep_name_map: HashMap<usize, HashMap<InternedString, HashSet<(usize, bool)>>>
Map of dependency names, used for building internal feature map for dep_name/feat_name syntax.
Key is the index of a package node, value is a map of dep_name to a
set of (pkg_node_index, is_optional)
.
Implementations§
source§impl<'a> Graph<'a>
impl<'a> Graph<'a>
fn new(package_map: HashMap<PackageId, &'a Package>) -> Graph<'a>
sourcefn add_node(&mut self, node: Node) -> usize
fn add_node(&mut self, node: Node) -> usize
Adds a new node to the graph, returning its new index.
sourcepub fn connected_nodes(&self, from: usize, kind: &EdgeKind) -> Vec<usize>
pub fn connected_nodes(&self, from: usize, kind: &EdgeKind) -> Vec<usize>
Returns a list of nodes the given node index points to for the given kind.
sourcepub fn has_outgoing_edges(&self, index: usize) -> bool
pub fn has_outgoing_edges(&self, index: usize) -> bool
Returns true
if the given node has any outgoing edges.
sourcepub fn indexes_from_ids(&self, package_ids: &[PackageId]) -> Vec<usize>
pub fn indexes_from_ids(&self, package_ids: &[PackageId]) -> Vec<usize>
Given a slice of PackageIds, returns the indexes of all nodes that match.
pub fn package_for_id(&self, id: PackageId) -> &Package
fn package_id_for_index(&self, index: usize) -> PackageId
sourcepub fn is_cli_feature(&self, index: usize) -> bool
pub fn is_cli_feature(&self, index: usize) -> bool
Returns true
if the given feature node index is a feature enabled
via the command-line.
sourcepub fn from_reachable(&self, roots: &[usize]) -> Graph<'a>
pub fn from_reachable(&self, roots: &[usize]) -> Graph<'a>
Returns a new graph by removing all nodes not reachable from the given nodes.
sourcepub fn find_duplicates(&self) -> Vec<usize>
pub fn find_duplicates(&self) -> Vec<usize>
Returns a list of nodes that are considered “duplicates” (same package name, with different versions/features/source/etc.).
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Graph<'a>
impl<'a> !Send for Graph<'a>
impl<'a> !Sync for Graph<'a>
impl<'a> Unpin for Graph<'a>
impl<'a> UnwindSafe for Graph<'a>
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> 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> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 240 bytes