[][src]Struct guppy::graph::PackageGraph

pub struct PackageGraph { /* fields omitted */ }

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]

Returns an iterator over all the package IDs in this graph.

pub fn packages(
    &self
) -> impl Iterator<Item = &PackageMetadata> + ExactSizeIterator
[src]

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.

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, DependencyLink) -> bool
[src]

Keeps all edges that return true from the visit closure, and removes the others.

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]

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.

For repeated queries, consider using new_depends_cache to speed up queries.

Returns the direct dependencies for the given package ID in the specified direction.

Returns the direct dependencies for the given package ID.

Returns the direct reverse dependencies for the given package ID.

impl PackageGraph[src]

Selectors

The methods in this section create package selectors, which are queries over subsets of this package graph. Use the methods here for queries based on transitive dependencies.

pub fn select_all<'g>(&'g self) -> PackageSelect<'g>[src]

Creates a new selector that returns all members of this package graph.

pub fn select_transitive_deps_directed<'g, 'a>(
    &'g self,
    package_ids: impl IntoIterator<Item = &'a PackageId>,
    dep_direction: DependencyDirection
) -> Result<PackageSelect<'g>, Error>
[src]

Creates a new selector that returns transitive dependencies of the given packages in the specified direction.

Returns an error if any package IDs are unknown.

pub fn select_transitive_deps<'g, 'a>(
    &'g self,
    package_ids: impl IntoIterator<Item = &'a PackageId>
) -> Result<PackageSelect<'g>, Error>
[src]

Creates a new selector that returns transitive dependencies of the given packages.

Returns an error if any package IDs are unknown.

pub fn select_transitive_reverse_deps<'g, 'a>(
    &'g self,
    package_ids: impl IntoIterator<Item = &'a PackageId>
) -> Result<PackageSelect<'g>, Error>
[src]

Creates a new selector that returns transitive reverse dependencies of the given packages.

Returns an error if any package IDs are unknown.

Trait Implementations

impl Clone for PackageGraph[src]

impl Debug for PackageGraph[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]