tokmd_analysis_types/api_surface.rs
1//! API surface receipt DTOs.
2//!
3//! These contract types remain re-exported from the crate root to preserve
4//! existing `tokmd_analysis_types::...` names.
5
6use std::collections::BTreeMap;
7
8use serde::{Deserialize, Serialize};
9
10/// Public API surface analysis report.
11///
12/// Computes public export ratios per language and module by scanning
13/// source files for exported symbols (pub fn, export function, etc.).
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct ApiSurfaceReport {
16 /// Total items discovered across all languages.
17 pub total_items: usize,
18 /// Items with public visibility.
19 pub public_items: usize,
20 /// Items with internal/private visibility.
21 pub internal_items: usize,
22 /// Ratio of public to total items (0.0-1.0).
23 pub public_ratio: f64,
24 /// Ratio of documented public items (0.0-1.0).
25 pub documented_ratio: f64,
26 /// Per-language breakdown.
27 pub by_language: BTreeMap<String, LangApiSurface>,
28 /// Per-module breakdown.
29 pub by_module: Vec<ModuleApiRow>,
30 /// Top exporters (files with most public items).
31 pub top_exporters: Vec<ApiExportItem>,
32}
33
34/// Per-language API surface breakdown.
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct LangApiSurface {
37 /// Total items in this language.
38 pub total_items: usize,
39 /// Public items in this language.
40 pub public_items: usize,
41 /// Internal items in this language.
42 pub internal_items: usize,
43 /// Public ratio for this language.
44 pub public_ratio: f64,
45}
46
47/// Per-module API surface row.
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct ModuleApiRow {
50 /// Module path.
51 pub module: String,
52 /// Total items in this module.
53 pub total_items: usize,
54 /// Public items in this module.
55 pub public_items: usize,
56 /// Public ratio for this module.
57 pub public_ratio: f64,
58}
59
60/// A file that exports many public items.
61#[derive(Debug, Clone, Serialize, Deserialize)]
62pub struct ApiExportItem {
63 /// File path.
64 pub path: String,
65 /// Language of the file.
66 pub lang: String,
67 /// Number of public items exported.
68 pub public_items: usize,
69 /// Total items in the file.
70 pub total_items: usize,
71}