distributed_verification/
statistics.rs

1use indexmap::IndexMap;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Default, Clone, Serialize, Deserialize)]
5pub struct Stat {
6    pub local: LocalCrateFnDefs,
7    pub external: ExternalCrates,
8}
9
10/// External crates excluding the local one.
11#[derive(Debug, Default, Clone, Serialize, Deserialize)]
12pub struct ExternalCrates {
13    /// Count of external crates.
14    pub count: usize,
15    // /// Sorted by name.
16    //pub crates: Vec<String>,
17}
18
19/// Metrics based on `Vec<FnDef>`.
20#[derive(Debug, Default, Clone, Serialize, Deserialize)]
21pub struct LocalCrateFnDefs {
22    pub attrs: CountAttrs,
23    pub fn_defs: FnDefs,
24    pub kanitools: KaniTools,
25}
26
27#[derive(Debug, Default, Clone, Serialize, Deserialize)]
28pub struct KaniTools {
29    /// The FnDef count in each attribute from annotated_functions.
30    pub count: IndexMap<String, usize>,
31    /// FnDefs that are annotated with `#[kanitools]`, group by attributes.
32    /// A function may appear under multiple attributes.
33    pub annotated_functions: IndexMap<String, Vec<String>>,
34}
35
36#[derive(Debug, Default, Clone, Serialize, Deserialize)]
37pub struct CountAttrs {
38    /// FnDefs that annotated with tool attributes, including kanitools, clippy, and others.
39    pub all_tool_attrs: usize,
40    /// FnDefs annotated with `#[kanitools::*]`.
41    pub kanitools: usize,
42}
43
44// A FnDef is from like a normal function, method, or that in a trait.
45#[derive(Debug, Default, Clone, Serialize, Deserialize)]
46pub struct FnDefs {
47    /// Count of all FnDefs.
48    pub total: usize,
49    /// FnDefs annotated with kanitool.
50    pub kanitools: KaniToolsFnDefs,
51}
52
53#[derive(Debug, Default, Clone, Serialize, Deserialize)]
54pub struct KaniToolsFnDefs {
55    pub count: usize,
56    pub names: Vec<String>,
57}