provenant/output_schema/
summary.rs1use serde::{Deserialize, Serialize};
5
6use super::license_clarity_score::OutputLicenseClarityScore;
7use super::tally_entry::OutputTallyEntry;
8
9#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
10pub struct OutputSummary {
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub declared_license_expression: Option<String>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 pub license_clarity_score: Option<OutputLicenseClarityScore>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 pub declared_holder: Option<String>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 pub primary_language: Option<String>,
19 #[serde(default, skip_serializing_if = "Vec::is_empty")]
20 pub other_license_expressions: Vec<OutputTallyEntry>,
21 #[serde(default, skip_serializing_if = "Vec::is_empty")]
22 pub other_holders: Vec<OutputTallyEntry>,
23 #[serde(default, skip_serializing_if = "Vec::is_empty")]
24 pub other_languages: Vec<OutputTallyEntry>,
25}
26
27impl From<&crate::models::Summary> for OutputSummary {
28 fn from(value: &crate::models::Summary) -> Self {
29 Self {
30 declared_license_expression: value.declared_license_expression.clone(),
31 license_clarity_score: value
32 .license_clarity_score
33 .as_ref()
34 .map(OutputLicenseClarityScore::from),
35 declared_holder: value.declared_holder.clone(),
36 primary_language: value.primary_language.clone(),
37 other_license_expressions: value
38 .other_license_expressions
39 .iter()
40 .map(OutputTallyEntry::from)
41 .collect(),
42 other_holders: value
43 .other_holders
44 .iter()
45 .map(OutputTallyEntry::from)
46 .collect(),
47 other_languages: value
48 .other_languages
49 .iter()
50 .map(OutputTallyEntry::from)
51 .collect(),
52 }
53 }
54}