ecitygml_io/validate/
report.rs

1use serde::{Deserialize, Serialize};
2
3use std::fs;
4use std::path::Path;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Report {
8    pub(crate) statistics: ReportStatistics,
9    pub(crate) xml_elements: Vec<ReportElement>,
10    pub(crate) gml_id_duplicates: Vec<(String, usize)>,
11    pub(crate) broken_object_relations: Vec<String>,
12    pub(crate) broken_predecessor_hrefs: Vec<String>,
13    pub(crate) broken_successor_hrefs: Vec<String>,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct ReportStatistics {
18    pub(crate) number_of_gml_duplicates: usize,
19    pub(crate) number_of_broken_object_relations: usize,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct ReportElement {
24    pub(crate) element_name: String,
25    pub(crate) number_total: usize,
26    pub(crate) number_with_gml_id: usize,
27    pub(crate) number_without_gml_id: usize,
28}
29
30impl Report {
31    pub fn write(&self, path: impl AsRef<Path>) {
32        let yaml = serde_yaml::to_string(&self).unwrap();
33        fs::write(path, yaml).expect("Unable to write file");
34    }
35}