Skip to main content

Crate cargo_build_doctor

Crate cargo_build_doctor 

Source
Expand description

The library half of cargo-build-doctor.

The CLI is the main product. This crate exists for tooling that wants the same capture, storage, and analysis pipeline without scraping terminal output.

The flow is usually short. Load workspace metadata, capture a session, analyze it, then compare it against a baseline when something rebuilt and should not have.

use cargo_build_doctor::{
    analyze_session, capture_session, load_workspace_metadata, BuildDoctorConfig,
    CaptureOptions,
};

let workspace = load_workspace_metadata()?;
let config = BuildDoctorConfig::load_or_default(&workspace.workspace_root)?;
let outcome = capture_session(
    &workspace,
    &config,
    CaptureOptions {
        cargo_args: vec!["check".into(), "--workspace".into()],
        enable_timings: true,
        hash_all_inputs: false,
    },
)?;
let analysis = analyze_session(&outcome.session, &config);
println!("{}", analysis.recommendations.len());

Most of the values that move between those steps live in model. They stay plain on purpose because sessions get serialized, diffed later, and sometimes moved between machines.

Re-exports§

pub use analysis::diff::compare_sessions;
pub use analysis::diff::CiCheckThresholds;
pub use analysis::diff::ComparisonResult;
pub use analysis::diff::FailOn;
pub use analysis::rebuild_causes::explain_rebuilds;
pub use analysis::rebuild_causes::CauseCandidate;
pub use analysis::rebuild_causes::RebuildCause;
pub use analysis::rebuild_causes::RebuildExplanation;
pub use analysis::session_analysis::analyze_session;
pub use analysis::session_analysis::SessionAnalysis;
pub use collect::metadata::load_workspace_metadata;
pub use collect::metadata::WorkspaceMetadata;
pub use config::BuildDoctorConfig;
pub use driver::cargo_runner::capture_session;
pub use driver::cargo_runner::measure_feature;
pub use driver::cargo_runner::measure_linker;
pub use driver::cargo_runner::measure_profile;
pub use driver::cargo_runner::CaptureOptions;
pub use driver::cargo_runner::CaptureOutcome;
pub use driver::cargo_runner::CommandSpec;
pub use model::CapturedSession;
pub use model::FeatureMeasurement;
pub use model::Recommendation;
pub use model::Session;
pub use patch::PatchBundle;
pub use patch::PatchPlanner;
pub use recommend::catalog::rule_catalog;
pub use recommend::catalog::rule_spec;
pub use recommend::catalog::RuleSpec;
pub use recommend::engine::RecommendationEngine;
pub use recommend::engine::WorkspaceHealthSnapshot;
pub use store::ExportStore;
pub use store::SessionStore;
pub use store::SessionStorePaths;

Modules§

analysis
collect
config
driver
model
patch
recommend
store