Skip to main content

Crate codedash_schemas

Crate codedash_schemas 

Source
Expand description

Stable public schema for codedash code metrics output.

This crate defines the external contract for codedash’s analysis JSON. It is decoupled from codedash’s internal domain model via an Anti-Corruption Layer (ACL), so internal refactoring does not break external consumers.

§Design: Anti-Corruption Layer

codedash maintains two separate type hierarchies:

  1. Internal domain model (codedash::domain::ast) — optimized for parsing and enrichment logic. May change across codedash versions.
  2. Public schema (this crate) — stable, versioned contract for external consumers.

The ACL boundary (codedash::port::schema) converts domain types into these schema types via From implementations. This is the only place where the two models touch. As a result:

  • Internal refactoring in codedash never breaks consumers of this crate.
  • This crate carries minimal dependencies (serde only).
  • Breaking changes to the schema follow semver.

§For Rust consumers

use codedash_schemas::AstData;

let data: AstData = serde_json::from_str(json).unwrap();

§For non-Rust consumers (JSON Schema)

Enable the schema feature and generate a JSON Schema file:

let schema = schemars::schema_for!(codedash_schemas::AstData);
println!("{}", serde_json::to_string_pretty(&schema).unwrap());

The generated schema can then be used by TypeScript, Python, Go, etc. to validate or generate types for codedash output.

§Optional features

  • schema — derives [schemars::JsonSchema] on all types, enabling JSON Schema generation via schemars::schema_for!.

Re-exports§

pub use analyze::AnalyzeResult;
pub use analyze::Binding;
pub use analyze::EvalEntry;
pub use analyze::Group;
pub use analyze::PerceptValues;

Modules§

analyze
Evaluated analysis output schema (codedash analyze -o json).

Structs§

AstData
Top-level AST output from a codedash analysis run.
CallInfo
A call reference from a function body to an imported symbol.
Edge
A dependency edge between two files.
FileData
Per-file AST data.
ImportInfo
An internal import (e.g. use crate::domain::ast::AstData).
NodeData
A single AST node (function, struct, enum, impl, etc.).