multiversx_sc_meta_lib/
code_report_json.rs

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
use serde::{Deserialize, Serialize};

use crate::tools::report_creator::ReportCreator;

#[derive(Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CodeReportJson {
    #[serde(default)]
    pub path: String,

    #[serde(default)]
    pub size: usize,

    #[serde(default)]
    pub has_allocator: bool,

    #[serde(default)]
    pub has_panic: String,
}

impl CodeReportJson {
    pub fn new(report: &ReportCreator, size: usize) -> CodeReportJson {
        CodeReportJson {
            path: report.path.clone(),
            size,
            has_allocator: report.has_allocator,
            has_panic: report.has_panic.to_string(),
        }
    }
}