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§
- Abstraction
Thresholds - Thresholds used when categorising a crate as abstract or concrete.
- Class
Info - Metadata about a type defined in a crate.
- Cohesion
Thresholds - Thresholds used to evaluate relational cohesion.
- Config
- Top-level structure for configuration files.
- Crate
Detail - Detailed analysis results for a single crate.
- Distance
Thresholds - Thresholds for evaluating distance from the main sequence.
- Evaluation
- Human readable evaluation for a set of metrics.
- Evaluation
Thresholds - Groups together threshold values used when evaluating metrics.
- Instability
Thresholds - Thresholds used to categorise crate stability.
- Metrics
- Quantitative metrics describing the coupling and cohesion of a crate.
- Metrics
Result - Metrics accompanied by their qualitative evaluation, used for output.
Enums§
- Abstraction
Eval - Qualitative evaluation of a crate’s level of abstraction.
- Class
Kind - Represents the kind of item defined within a crate.
- Cohesion
Eval - Qualitative evaluation of relational cohesion.
- Crate
Kind - Specifies whether a crate belongs to the current workspace or is an external dependency.
- Distance
Eval - Qualitative evaluation of the normalised distance from the main sequence.
- Stability
Eval - 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
CrateDetailinformation for multiple crates. - analyze_
workspace_ details_ with_ thresholds - Produce full
CrateDetailinformation 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
implblock 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.