Skip to main content

Crate cargo_anatomy

Crate cargo_anatomy 

Source
Expand description

Utilities for analyzing Rust crates and computing package metrics.

The library parses Rust source files and builds a dependency graph of the types that appear within a crate. From this graph a number of classic software metrics are derived, such as efferent/afferent coupling and relational cohesion. These building blocks are used by the accompanying cargo-anatomy binary, but the functions are generic enough to be consumed by other tools as well.

Macros§

loc_try
Try expression and attach location info on error.

Structs§

AbstractionThresholds
Thresholds used when categorising a crate as abstract or concrete.
ClassInfo
Metadata about a type defined in a crate.
CohesionThresholds
Thresholds used to evaluate relational cohesion.
Config
Top-level structure for configuration files.
CrateDetail
Detailed analysis results for a single crate.
DistanceThresholds
Thresholds for evaluating distance from the main sequence.
Evaluation
Human readable evaluation for a set of metrics.
EvaluationThresholds
Groups together threshold values used when evaluating metrics.
InstabilityThresholds
Thresholds used to categorise crate stability.
Metrics
Quantitative metrics describing the coupling and cohesion of a crate.
MetricsResult
Metrics accompanied by their qualitative evaluation, used for output.

Enums§

AbstractionEval
Qualitative evaluation of a crate’s level of abstraction.
ClassKind
Represents the kind of item defined within a crate.
CohesionEval
Qualitative evaluation of relational cohesion.
CrateKind
Specifies whether a crate belongs to the current workspace or is an external dependency.
DistanceEval
Qualitative evaluation of the normalised distance from the main sequence.
StabilityEval
Qualitative evaluation of stability based on dependency ratios.

Functions§

analyze_files
Analyze parsed files to produce package metrics.
analyze_package
Parse a package’s source files and compute metrics.
analyze_workspace
Analyse multiple crates together so cross-crate dependencies can be counted.
analyze_workspace_details
Produce full CrateDetail information for multiple crates.
analyze_workspace_details_with_thresholds
Produce full CrateDetail information for multiple crates using custom thresholds.
analyze_workspace_with_thresholds
Analyse multiple crates together using custom evaluation thresholds.
collect_defined
Traverse parsed syntax trees and collect all type definitions, counting traits.
collect_methods
Map method names to their return types for each impl block or trait.
collect_reexports
Collect re-exported items from workspace crates.
collect_trait_bounds
Collect trait inheritance information for each trait.
dependency_cycles
Detect cycles in the crate dependency graph.
error_with_location
Wrap an error with file and line information.
evaluate_metrics
Evaluate a set of metrics using the library’s default thresholds.
evaluate_metrics_with
Evaluate metrics using custom thresholds.
parse_package
Parse all Rust source files belonging to the given package.