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