Crate krates[−][src]
Transforms the output of [cargo metadata
] into a graph, Krates
, where
crates are nodes and dependency links are edges.
use krates::{Builder, Cmd, Krates, cm, petgraph}; fn main() -> Result<(), krates::Error> { let mut cmd = Cmd::new(); cmd.manifest_path("path/to/a/Cargo.toml"); // Enable all features, works for either an entire workspace or a single crate cmd.all_features(); let mut builder = Builder::new(); // Let's filter out any crates that aren't used by x86_64 windows builder.include_targets(std::iter::once(("x86_64-pc-windows-msvc", vec![]))); let krates: Krates = builder.build(cmd, |pkg: cm::Package| { println!("Crate {} was filtered out", pkg.id); })?; // Print a dot graph of the entire crate graph println!("{:?}", petgraph::dot::Dot::new(krates.graph())); Ok(()) }
Re-exports
pub use cargo_metadata as cm; |
pub use cfg_expr; |
pub use petgraph; |
pub use semver; |
pub use cm::camino; |
Structs
Builder | A builder used to create a Krates graph, either by running a cargo metadata
command, or using an already deserialized |
Cmd | An alternative to |
Edge | The default type used for edges in the crate graph. |
Krates | A crate graph. Each unique crate is a node, and each unique dependency between 2 crates is an edge. |
Node | A node in the crate graph. |
NoneFilter | For when you just want to satisfy |
PkgSpec | A package specification. See cargo pkgid for more information on this. |
Utf8Path | A slice of a UTF-8 path (akin to |
Utf8PathBuf | An owned, mutable UTF-8 path (akin to |
Enums
DepKind | The dependency kind. A crate can depend on the same crate multiple times with different dependency kinds |
Error | Errors that can occur when acquiring metadata to create a graph from |
Scope | The scope for which a dependency kind will be ignored |
Target |
Traits
KrateDetails | A trait that can be applied to the type stored in the graph nodes to give
additional features on |
OnFilter | Trait used to report back any crates that are completely ignored in the final crate graph that is built. This occurs when the crate has no dependents any longer due to the applied filters. |
Type Definitions
Kid | A crate’s unique identifier |
NodeId | A node identifier. |