1use std::collections::HashMap;
2
3#[derive(Debug, Clone, PartialEq, Eq, Default)]
6pub struct InternedHeaders<'a>(pub HashMap<usize, &'a str>);
7
8#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct DataRecord<'a> {
11 pub structure: Structure,
12 pub structure_id: StructureId<'a>,
13 pub structure_name: Option<StructureName<'a>>,
15 pub action: Action,
17 pub series_key: Option<&'a str>,
19 pub obs_key: Option<&'a str>,
20 pub components: HashMap<usize, &'a str>,
21 pub other: HashMap<usize, &'a str>,
22}
23
24#[derive(Debug, Clone, PartialEq, Eq)]
26pub struct MetadataRecord<'a> {
27 pub md_structure: Structure,
28 pub md_structure_id: StructureId<'a>,
29 pub md_structure_name: Option<StructureName<'a>>,
31 pub metadataset_id: &'a str,
32 pub metadataset_name: Option<&'a str>,
34 pub action: Action,
36 pub target_types: Vec<&'a str>,
37 pub target_ids: Vec<&'a str>,
38 pub target_names: Option<&'a str>,
40 pub components: HashMap<usize, &'a str>,
41 pub others: HashMap<usize, &'a str>,
42}
43
44#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46pub enum Structure {
47 DataFlow,
48 DataStructure,
49 DataProvision,
50}
51
52#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
54pub struct StructureId<'a> {
55 agency: &'a str,
56 artefact_id: &'a str,
57 version: &'a str,
58}
59
60impl<'a> StructureId<'a> {
61 pub const fn agency(&self) -> &'a str {
62 self.agency
63 }
64
65 pub const fn artefact_id(&self) -> &'a str {
66 self.artefact_id
67 }
68
69 pub const fn version(&self) -> &'a str {
70 self.version
71 }
72}
73
74#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
76pub struct StructureName<'a> {
77 pub id: StructureId<'a>,
78 pub localized: &'a str,
79}
80
81#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
86pub enum Action {
87 Append,
88 Replace,
89 Delete,
90 #[default]
91 Information,
92}
93
94impl TryFrom<char> for Action {
95 type Error = ();
96 fn try_from(value: char) -> Result<Self, Self::Error> {
97 match value {
98 'A' => Ok(Self::Append),
99 'R' => Ok(Self::Replace),
100 'D' => Ok(Self::Delete),
101 'I' => Ok(Self::Information),
102 _ => Err(()),
103 }
104 }
105}
106
107#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
110pub struct DataOptions {
111 pub labels: Labels,
112 pub time_format: TimeFormat,
113 pub keys: Keys,
114}
115
116#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
119pub struct MetadataOptions {
120 pub labels: Labels,
121}
122
123#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
126pub enum Labels {
127 #[default]
128 Id,
129 Name,
130 Both,
131}
132
133#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
136pub enum TimeFormat {
137 #[default]
138 Original,
139 Normalized,
140}
141
142#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
146pub enum Keys {
147 #[default]
148 None,
149 Obs,
150 Series,
151 Both,
152}