[−][src]Struct guppy::graph::PackageGraph
A graph of packages and dependencies between them, parsed from metadata returned by cargo metadata
.
For examples on how to use PackageGraph
, see
the examples
directory
in this crate.
Methods
impl PackageGraph
[src]
pub fn from_command(command: &mut MetadataCommand) -> Result<Self, Error>
[src]
Constructs a package graph from the given command.
pub fn from_json(json: impl AsRef<str>) -> Result<Self, Error>
[src]
Constructs a package graph from the given JSON output of cargo metadata
.
pub fn new(metadata: Metadata) -> Result<Self, Error>
[src]
Constructs a package graph from the given metadata.
pub fn workspace(&self) -> Workspace
[src]
Returns information about the workspace.
pub fn package_ids(
&self
) -> impl Iterator<Item = &PackageId> + ExactSizeIterator
[src]
&self
) -> impl Iterator<Item = &PackageId> + ExactSizeIterator
Returns an iterator over all the package IDs in this graph.
pub fn packages(
&self
) -> impl Iterator<Item = &PackageMetadata> + ExactSizeIterator
[src]
&self
) -> impl Iterator<Item = &PackageMetadata> + ExactSizeIterator
Returns an iterator over all the packages in this graph.
pub fn package_count(&self) -> usize
[src]
Returns the number of packages in this graph.
pub fn link_count(&self) -> usize
[src]
Returns the number of links in this graph.
pub fn metadata(&self, package_id: &PackageId) -> Option<&PackageMetadata>
[src]
Returns the metadata for the given package ID.
pub fn retain_edges<F>(&mut self, visit: F) where
F: Fn(&PackageGraphData, PackageLink) -> bool,
[src]
F: Fn(&PackageGraphData, PackageLink) -> bool,
Keeps all edges that return true from the visit closure, and removes the others.
For an equivalent operation which doesn't mutate the graph, see
PackageQuery::resolve_with
and PackageQuery::resolve_with_fn
.
The order edges are visited is not specified.
pub fn new_depends_cache(&self) -> DependsCache
[src]
Creates a new cache for depends_on
queries.
The cache is optional but can speed up some queries.
pub fn depends_on(
&self,
package_a: &PackageId,
package_b: &PackageId
) -> Result<bool, Error>
[src]
&self,
package_a: &PackageId,
package_b: &PackageId
) -> Result<bool, Error>
Returns true if package_a
depends (directly or indirectly) on package_b
.
In other words, this returns true if package_b
is a (possibly transitive) dependency of
package_a
.
This also returns true if package_a
is the same as package_b
.
For repeated queries, consider using new_depends_cache
to speed up queries.
pub fn directly_depends_on(
&self,
package_a: &PackageId,
package_b: &PackageId
) -> Result<bool, Error>
[src]
&self,
package_a: &PackageId,
package_b: &PackageId
) -> Result<bool, Error>
Returns true if package_a
directly depends on package_b
.
In other words, this returns true if package_b
is a direct dependency of package_a
.
This returns false if package_a
is the same as package_b
.
pub fn cycles(&self) -> Cycles
[src]
Returns information about dependency cycles in this graph.
For more information, see the documentation for Cycles
.
pub fn dep_links_directed<'g>(
&'g self,
package_id: &PackageId,
dep_direction: DependencyDirection
) -> Option<impl Iterator<Item = PackageLink<'g>> + 'g>
[src]
&'g self,
package_id: &PackageId,
dep_direction: DependencyDirection
) -> Option<impl Iterator<Item = PackageLink<'g>> + 'g>
Returns the direct dependencies for the given package ID in the specified direction.
pub fn dep_links<'g>(
&'g self,
package_id: &PackageId
) -> Option<impl Iterator<Item = PackageLink<'g>> + 'g>
[src]
&'g self,
package_id: &PackageId
) -> Option<impl Iterator<Item = PackageLink<'g>> + 'g>
Returns the direct dependencies for the given package ID.
pub fn reverse_dep_links<'g>(
&'g self,
package_id: &PackageId
) -> Option<impl Iterator<Item = PackageLink<'g>> + 'g>
[src]
&'g self,
package_id: &PackageId
) -> Option<impl Iterator<Item = PackageLink<'g>> + 'g>
Returns the direct reverse dependencies for the given package ID.
impl PackageGraph
[src]
Helpers for property testing
The methods in this section allow a PackageGraph
to be used in property-based testing
scenarios.
Currently, proptest 0.9 is supported if the proptest09
feature
is enabled.
pub fn prop09_id_strategy<'g>(
&'g self
) -> impl Strategy<Value = &'g PackageId> + 'g
[src]
&'g self
) -> impl Strategy<Value = &'g PackageId> + 'g
Returns a Strategy
that generates random package IDs from this graph.
Requires the proptest09
feature to be enabled.
Panics
Panics if there are no packages in this PackageGraph
.
pub fn prop09_link_strategy<'g>(
&'g self
) -> impl Strategy<Value = PackageLink<'g>> + 'g
[src]
&'g self
) -> impl Strategy<Value = PackageLink<'g>> + 'g
Returns a Strategy
that generates random dependency links from this graph.
Requires the proptest09
feature to be enabled.
Panics
Panics if there are no dependency edges in this PackageGraph
.
pub fn prop09_resolver_strategy<'g>(
&'g self
) -> impl Strategy<Value = Prop09Resolver> + 'g
[src]
&'g self
) -> impl Strategy<Value = Prop09Resolver> + 'g
Returns a Strategy
that generates a random PackageResolver
instance from this graph.
Requires the proptest09
feature to be enabled.
impl PackageGraph
[src]
Queries
The methods in this section create queries over subsets of this package graph. Use the methods here to analyze transitive dependencies.
pub fn query_workspace(&self) -> PackageQuery
[src]
Creates a new forward query over the entire workspace.
query_workspace
will select all workspace packages and their transitive dependencies.
pub fn query_directed<'g, 'a>(
&'g self,
package_ids: impl IntoIterator<Item = &'a PackageId>,
dep_direction: DependencyDirection
) -> Result<PackageQuery<'g>, Error>
[src]
&'g self,
package_ids: impl IntoIterator<Item = &'a PackageId>,
dep_direction: DependencyDirection
) -> Result<PackageQuery<'g>, Error>
Creates a new query that returns transitive dependencies of the given packages in the specified direction.
Returns an error if any package IDs are unknown.
pub fn query_forward<'g, 'a>(
&'g self,
package_ids: impl IntoIterator<Item = &'a PackageId>
) -> Result<PackageQuery<'g>, Error>
[src]
&'g self,
package_ids: impl IntoIterator<Item = &'a PackageId>
) -> Result<PackageQuery<'g>, Error>
Creates a new query that returns transitive dependencies of the given packages.
Returns an error if any package IDs are unknown.
pub fn query_reverse<'g, 'a>(
&'g self,
package_ids: impl IntoIterator<Item = &'a PackageId>
) -> Result<PackageQuery<'g>, Error>
[src]
&'g self,
package_ids: impl IntoIterator<Item = &'a PackageId>
) -> Result<PackageQuery<'g>, Error>
Creates a new query that returns transitive reverse dependencies of the given packages.
Returns an error if any package IDs are unknown.
impl PackageGraph
[src]
pub fn resolve_all(&self) -> PackageSet
[src]
Creates a new PackageSet
consisting of all members of this package graph.
This is normally the same as query_workspace().resolve()
, but can differ in some cases:
- if packages have been replaced with
[patch]
or[replace]
- if some edges have been removed from this graph with
retain_edges
.
In most situations, query_workspace
is preferred. Use resolve_all
if you know you need
parts of the graph that aren't accessible from the workspace.
Trait Implementations
impl Clone for PackageGraph
[src]
fn clone(&self) -> PackageGraph
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PackageGraph
[src]
Auto Trait Implementations
impl RefUnwindSafe for PackageGraph
impl Send for PackageGraph
impl Sync for PackageGraph
impl Unpin for PackageGraph
impl UnwindSafe for PackageGraph
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,