Skip to main content

Crate source_mesh_core

Crate source_mesh_core 

Source
Expand description

§source-mesh-core

Analyze Rust file and folder dependencies, export DOT, Mermaid, or GraphML diagrams, and produce file and folder cycle reports. The source-mesh package provides the CLI; this package exposes the same pipeline without command-line parsing.

use std::path::PathBuf;
use source_mesh_core::Input;
use source_mesh_core::Request;
use source_mesh_core::export::Format;

let index = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
    .join("src").join("fixtures").join("dependency-graph.scip");
let request = Request::builder()
    .input(Input::ScipFile(index))
    .format(Format::Mermaid)
    .build();
let mut diagram = Vec::new();
source_mesh_core::run(&request, &mut diagram)?;
assert!(!diagram.is_empty());

To analyze project sources, use Input::Project(Project::new(project_path, configuration)). This runs rust-analyzer and requires the Rust toolchain, rust-analyzer, and rust-src; replaying a saved index does not. configuration is an optional path to rust-analyzer JSON configuration. All boolean options default to false. Configure reports and cycle gating through CycleOptions::builder() and pass the result to the request’s .cycles(...) setter. Reports default to at most DEFAULT_CYCLE_LIMIT simple cycles each. Pass analyzer_options::Options::new(true) to .analyzer(...) for verbose diagnostics.

Validation and analysis errors preserve existing outputs. Cycle gating with CycleOptions::builder().fail_on_cycles(true).build() reports failure after writing requested outputs. Output I/O errors can leave earlier files written; output writes are not a transaction.

The low-level analyzer, graph, cycle, and exporter APIs remain available.

§Development

The package includes the saved SCIP fixture for offline tests and the API example. Cargo excludes nested fixture packages from published archives, so the ignored tests that run rust-analyzer and the index regeneration tool require a repository checkout. Fixture projects retain standalone workspaces. Run the regeneration tool from the checkout:

cargo run -p source-mesh-core --example regenerate-dependency-graph-scip

Modules§

analyzer_options
backend
cycle_report
cycles
export
model
scip_backend

Structs§

CycleOptions
Cycle highlighting, reports, and failure policy.
Project
A Rust project and its optional rust-analyzer JSON configuration.
Request
An analysis and export operation. Boolean options are disabled by default.

Enums§

Input
Analyze a project or replay an existing SCIP index.

Constants§

DEFAULT_CYCLE_LIMIT
Maximum number of simple cycles in each report by default.

Functions§

run
Analyze and export dependencies, writing the diagram to the supplied writer unless the request selects an output file.