20 releases (6 breaking)

new 0.6.3 Jan 11, 2021
0.6.2 Dec 10, 2020
0.5.0 Jun 20, 2020
0.1.6 Mar 12, 2020
0.1.2 Nov 26, 2019

#28 in Data structures

Download history 2774/week @ 2020-09-27 2856/week @ 2020-10-04 1271/week @ 2020-10-11 913/week @ 2020-10-18 1255/week @ 2020-10-25 1063/week @ 2020-11-01 1352/week @ 2020-11-08 1244/week @ 2020-11-15 160/week @ 2020-11-22 1805/week @ 2020-11-29 3544/week @ 2020-12-06 1734/week @ 2020-12-13 1902/week @ 2020-12-20 1662/week @ 2020-12-27 2869/week @ 2021-01-03 3648/week @ 2021-01-10

7,135 downloads per month
Used in 6 crates (5 directly)

MIT/Apache

370KB
7K SLoC

guppy

guppy on crates.io Documentation (latest release) Documentation (master) License License

Track and query Cargo dependency graphs.

guppy provides a Rust interface to run queries over Cargo dependency graphs. guppy parses the output of cargo metadata, then presents a graph interface over it.

Optional features

  • proptest010: Support for property-based testing using the proptest framework.
  • rayon1: Support for parallel iterators through Rayon (preliminary work so far, more parallel iterators to be added in the future).
  • summaries: Support for writing out build summaries.

Examples

Print out all direct dependencies of a package:

use guppy::{CargoMetadata, PackageId};

// `guppy` accepts `cargo metadata` JSON output. Use a pre-existing fixture for these examples.
let metadata = CargoMetadata::parse_json(include_str!("../../fixtures/small/metadata1.json")).unwrap();
let package_graph = metadata.build_graph().unwrap();

// `guppy` provides several ways to get hold of package IDs. Use a pre-defined one for this
// example.
let package_id = PackageId::new("testcrate 0.1.0 (path+file:///fakepath/testcrate)");

// The `metadata` method returns information about the package, or `None` if the package ID
// wasn't recognized.
let package = package_graph.metadata(&package_id).unwrap();

// `direct_links` returns all direct dependencies of a package.
for link in package.direct_links() {
    // A dependency link contains `from()`, `to()` and information about the specifics of the
    // dependency.
    println!("direct dependency: {}", link.to().id());
}

For more examples, see the examples directory.

Contributing

See the CONTRIBUTING file for how to help out.

License

This project is available under the terms of either the Apache 2.0 license or the MIT license.

Dependencies

~3.5–5MB
~106K SLoC