provenant/output_schema/
output.rs1use serde::{Deserialize, Serialize};
2
3use super::facet_tallies::OutputFacetTallies;
4use super::file_info::OutputFileInfo;
5use super::header::OutputHeader;
6use super::license_reference::OutputLicenseReference;
7use super::license_rule_reference::OutputLicenseRuleReference;
8use super::package::OutputPackage;
9use super::summary::OutputSummary;
10use super::tallies::OutputTallies;
11use super::top_level_dependency::OutputTopLevelDependency;
12use super::top_level_license_detection::OutputTopLevelLicenseDetection;
13
14#[derive(Serialize, Deserialize, Debug)]
15pub struct Output {
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub summary: Option<OutputSummary>,
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub tallies: Option<OutputTallies>,
20 #[serde(skip_serializing_if = "Option::is_none")]
21 pub tallies_of_key_files: Option<OutputTallies>,
22 #[serde(skip_serializing_if = "Option::is_none")]
23 pub tallies_by_facet: Option<Vec<OutputFacetTallies>>,
24 pub headers: Vec<OutputHeader>,
25 pub packages: Vec<OutputPackage>,
26 pub dependencies: Vec<OutputTopLevelDependency>,
27 #[serde(default)]
28 pub license_detections: Vec<OutputTopLevelLicenseDetection>,
29 pub files: Vec<OutputFileInfo>,
30 pub license_references: Vec<OutputLicenseReference>,
31 pub license_rule_references: Vec<OutputLicenseRuleReference>,
32}
33
34impl From<&crate::models::Output> for Output {
35 fn from(value: &crate::models::Output) -> Self {
36 Self {
37 summary: value.summary.as_ref().map(OutputSummary::from),
38 tallies: value.tallies.as_ref().map(OutputTallies::from),
39 tallies_of_key_files: value.tallies_of_key_files.as_ref().map(OutputTallies::from),
40 tallies_by_facet: value
41 .tallies_by_facet
42 .as_ref()
43 .map(|v| v.iter().map(OutputFacetTallies::from).collect()),
44 headers: value.headers.iter().map(OutputHeader::from).collect(),
45 packages: value.packages.iter().map(OutputPackage::from).collect(),
46 dependencies: value
47 .dependencies
48 .iter()
49 .map(OutputTopLevelDependency::from)
50 .collect(),
51 license_detections: value
52 .license_detections
53 .iter()
54 .map(OutputTopLevelLicenseDetection::from)
55 .collect(),
56 files: value.files.iter().map(OutputFileInfo::from).collect(),
57 license_references: value
58 .license_references
59 .iter()
60 .map(OutputLicenseReference::from)
61 .collect(),
62 license_rule_references: value
63 .license_rule_references
64 .iter()
65 .map(OutputLicenseRuleReference::from)
66 .collect(),
67 }
68 }
69}