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