tokmd_analysis_types/
fun.rs1use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct FunReport {
10 pub eco_label: Option<EcoLabel>,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct EcoLabel {
15 pub score: f64,
16 pub label: String,
17 pub bytes: u64,
18 pub notes: String,
19}
20
21#[cfg(test)]
22mod tests {
23 use super::EcoLabel;
24
25 #[test]
26 fn eco_label_serde_roundtrip() -> Result<(), Box<dyn std::error::Error>> {
27 let label = EcoLabel {
28 score: 85.0,
29 label: "A".into(),
30 bytes: 1000,
31 notes: "Good".into(),
32 };
33 let json = serde_json::to_string(&label)?;
34 let back: EcoLabel = serde_json::from_str(&json)?;
35 assert_eq!(back.label, "A");
36 assert_eq!(back.bytes, 1000);
37 Ok(())
38 }
39}