sdmx_json 0.6.2

A Rust implementation of SDMX-JSON (Statistical Data and Metadata eXchange) using Serde
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
use crate::primitives::{
	Annotation, DataType, Link, LocalizedText, Meta, SdmxMessage, SentinelValue, StatusMessage,
};
use crate::structure::{CommonArtefactType, DataConstraint, MetadataConstraint};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use std::str::FromStr;

/// The top-level type of a JSON file that conforms to the
/// SDMX-JSON Structure Message format.
///
/// # Deserializing
/// ## From a string
/// ```no_run
/// use std::str::FromStr;
/// use std::fs::read_to_string;
/// use sdmx_json::structure::StructureMessage;
///
/// fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
///     let file = read_to_string("sdmx-data.json")?;
///     let message = StructureMessage::from_str(file.as_str())?;
///     Ok(())
/// }
/// ```
///
/// ## From a byte slice
/// ```no_run
/// use std::fs::read;
/// use sdmx_json::structure::StructureMessage;
///
/// fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
///     let file = read("sdmx-data.json")?;
///     let message = StructureMessage::try_from(file.as_slice())?;
///     Ok(())
/// }
/// ```
///
/// ## From a `serde_json::Value`
/// ```no_run
/// use serde_json::json;
/// use sdmx_json::structure::StructureMessage;
///
/// fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
///     let value = json!({}); // assuming this has content
///     let message = StructureMessage::try_from(value);
///     Ok(())
/// }
/// ```
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
pub struct StructureMessage {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub meta: Option<Meta>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data: Option<Data>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub errors: Option<Vec<StatusMessage>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

impl SdmxMessage for StructureMessage {
	type Data = Data;
	fn meta(&self) -> Option<&Meta> {
		self.meta.as_ref()
	}

	fn data(&self) -> Option<&Self::Data> {
		self.data.as_ref()
	}

	fn errors(&self) -> Option<&Vec<StatusMessage>> {
		self.errors.as_ref()
	}
}
impl<'a> TryFrom<&'a [u8]> for StructureMessage {
	type Error = serde_json::Error;
	fn try_from(slice: &'a [u8]) -> Result<Self, Self::Error> {
		serde_json::from_slice(slice)
	}
}

impl FromStr for StructureMessage {
	type Err = serde_json::Error;
	fn from_str(s: &str) -> Result<Self, Self::Err> {
		serde_json::from_str(s)
	}
}

impl TryFrom<Value> for StructureMessage {
	type Error = serde_json::Error;
	fn try_from(value: Value) -> Result<Self, Self::Error> {
		serde_json::from_value(value)
	}
}

/// The associated data with a structure message.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct Data {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_structures: Option<Vec<DataStructure>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_structures: Option<Vec<MetadataStructure>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub category_schemas: Option<Vec<CategoryScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub concept_schemas: Option<Vec<ConceptScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub concepts: Option<Vec<Codelist>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub geographic_codelists: Option<Vec<Codelist>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub geo_grid_codelists: Option<Vec<Codelist>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub value_lists: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub hierarchies: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub hierarchy_associations: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub agency_schemes: Option<Vec<AgencyScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_provider_schemes: Option<Vec<DataProviderScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_consumer_schemes: Option<Vec<DataConsumerScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_provider_schemes: Option<Vec<MetadataProviderScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub organisation_unit_schemes: Option<Vec<OrganizationUnitScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub dataflows: Option<Vec<Dataflow>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadataflows: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub reporting_taxonomies: Option<Vec<ReportingTaxonomy>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub provision_agreements: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_provision_agreements: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub structure_maps: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub representation_maps: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub concept_scheme_maps: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub category_scheme_maps: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub organisation_scheme_maps: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub reporting_taxonomy_maps: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub processes: Option<Vec<CommonArtefactType>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub categorisations: Option<Vec<Categorization>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_constraints: Option<Vec<DataConstraint>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_constraints: Option<Vec<MetadataConstraint>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub custom_type_schemes: Option<Vec<CustomTypeScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub vtl_mapping_schemes: Option<Vec<VtlMappingScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub name_personalisation_schemes: Option<Vec<NamePersonalizationScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub ruleset_schemes: Option<Vec<RulesetScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub transformation_schemes: Option<Vec<TransformationScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub user_defined_operator_schemes: Option<Vec<UserDefinedOperatorsScheme>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A primitive in the SDMX Informational Model which
/// describes a concept.
///
/// **Note**: Since there are many variants which contain
/// a somewhat large memory layout (and some much larger
/// than others), every variant is boxed to ensure a smaller
/// memory footprint for the entire enum.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub enum ArtefactType {
	DataStructures(Box<DataStructure>),
	MetadataStructures(Box<MetadataStructure>),
	CategorySchemes(Box<CategoryScheme>),
	ConceptSchemes(Box<ConceptScheme>),
	Codelists(Box<Codelist>),
	GeographicCodelists(Box<GeographyCodelist>),
	GeoGridCodelists(Box<GeoGridCodelist>),
	ValueLists(Box<CommonArtefactType>),
	Hierarchies(Box<CommonArtefactType>),
	HierarchyAssociations(Box<CommonArtefactType>),
	AgencySchemes(Box<AgencyScheme>),
	DataProviderSchemes(Box<DataProviderScheme>),
	DataConsumerSchemes(Box<DataConsumerScheme>),
	MetadataProviderSchemes(Box<MetadataProviderScheme>),
	OrganisationUnitSchemes(Box<OrganizationUnitScheme>),
	Dataflows(Box<Dataflow>),
	Metadataflows(Box<CommonArtefactType>),
	ReportingTaxonomies(Box<ReportingTaxonomy>),
	ProvisionAgreements(Box<CommonArtefactType>),
	MetadataProvisionAgreements(Box<CommonArtefactType>),
	StructureMaps(Box<CommonArtefactType>),
	RepresentationMaps(Box<CommonArtefactType>),
	ConceptSchemeMaps(Box<CommonArtefactType>),
	CategorySchemeMaps(Box<CommonArtefactType>),
	OrganisationSchemeMaps(Box<CommonArtefactType>),
	ReportingTaxonomyMaps(Box<CommonArtefactType>),
	Processes(Box<CommonArtefactType>),
	Categorisations(Box<Categorization>),
	DataConstraints(Box<DataConstraint>),
	MetadataConstraints(Box<MetadataConstraint>),
	CustomTypeSchemes(Box<CustomTypeScheme>),
	VtlMappingSchemes(Box<VtlMappingScheme>),
	NamePersonalisationSchemes(Box<NamePersonalizationScheme>),
	RulesetSchemes(Box<RulesetScheme>),
	TransformationSchemes(Box<TransformationScheme>),
	UserDefinedOperatorSchemes(Box<UserDefinedOperatorsScheme>),
}

/// An abstract generic item within an item scheme.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct Item {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub name: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub names: Option<LocalizedText>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub description: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub descriptions: Option<LocalizedText>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A collection of metadata concepts, their structure
/// and usage when used to collect or disseminate data.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct DataStructure {
	#[serde(flatten)]
	pub common: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_structure_components: Option<DataStructureComponents>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A structure of the grouping to the sets of structural concepts
/// that have a defined structural role in the data structure definition.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct DataStructureComponents {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub attribute_list: Option<AttributeList>,
	pub dimension_list: DimensionList,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub groups: Option<Vec<Group>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub measure_list: Option<MeasureList>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A list of attributes in the data structure definition.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct AttributeList {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub attributes: Option<Vec<Attribute>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_attribute_usages: Option<Vec<MetadataAttributeUsage>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A characteristic of an object or entity.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Attribute {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	pub links: Option<Vec<Link>>,
	pub usage: Usage,
	pub attribute_relationship: AttributeRelationship,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub measure_relationship: Option<Vec<String>>,
	pub concept_identity: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub concept_roles: Option<Vec<String>>,
	pub local_representation: LocalRepresentation,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// Indicates whether something is required or optional.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum Usage {
	Mandatory,
	Optional,
}

/// The association between an attribute and other
/// data structure definition components.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum AttributeRelationship {
	DataFlow(AttributeRelationshipDataflow),
	Dimensions(AttributeRelationshipDimensions),
	Groups(AttributeRelationshipGroups),
	Observations(AttributeRelationshipObservations),
}

/// A type of relationship where the attribute value varies per dataflow.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct AttributeRelationshipDataflow {
	/// This is intentionally an empty type.
	pub dataflow: (),
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A type of relationship where the attribute references dimensions
/// in the data structure definition. The attribute can either be a
/// group, series/section, or an observational attribute.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct AttributeRelationshipDimensions {
	pub dimensions: Option<Vec<String>>,
	pub are_dimensions_optional: Option<Vec<bool>>,
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A type of relationship where the attribute references
/// a unique group identifier.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct AttributeRelationshipGroups {
	pub group: String,
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A type of relationship where the attribute value may vary
/// with any of the local dimensions, and thus is dependent
/// upon the observed value.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct AttributeRelationshipObservations {
	/// This is intentionally an empty type.
	pub observation: (),
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The data representation of an attribute.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct LocalRepresentation {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub enumeration: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub enumeration_format: Option<EnumerationFormat>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub format: Option<Format>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub min_occurs: Option<usize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub max_occurs: Option<Occurrence>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The max occurrences of something, which can either
/// be an unsigned integer or unbounded (can occur without
/// any upper limit).
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub enum Occurrence {
	Signed(usize),
	Unbounded,
}

impl From<usize> for Occurrence {
	fn from(value: usize) -> Self {
		Self::Signed(value)
	}
}

/// A restricted version of [`Format`] that only allows facets
/// and text types applicable to codes.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct EnumerationFormat {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_type: Option<DataType>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_sequence: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub interval: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub start_value: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub end_value: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub time_interval: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub start_time: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub end_time: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub min_length: Option<usize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub max_length: Option<usize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub min_value: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub max_value: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub pattern: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The information for describing a range of data formats
/// restricted to the representations allowed for all components
/// except for target objects.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Format {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_type: Option<DataType>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_sequence: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub interval: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub start_value: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub end_value: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub time_interval: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub start_time: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub end_time: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub min_length: Option<usize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub max_length: Option<usize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub min_value: Option<isize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub max_value: Option<isize>,
	pub is_multilingual: bool,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub sentinel_value: Option<Vec<SentinelValue>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// Defines how a metadata attribute is used within
/// a data structure.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct MetadataAttributeUsage {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	pub metadata_attribute_reference: String,
	pub attribute_relationship: AttributeRelationship,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// Defines the order in which child dimensions will
/// appear in data formats.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct DimensionList {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub id: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<String>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub dimensions: Option<Vec<Dimension>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub time_dimensions: Option<TimeDimension>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A dimension which represents a statistical series,
/// such as a time series.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Dimension {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub id: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	pub position: usize,
	pub concept_identity: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub concept_roles: Option<Vec<String>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub local_representation: Option<LocalRepresentation>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A statistical series representing time.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct TimeDimension {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub id: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	pub concept_identity: String,
	pub local_representation: LocalRepresentation,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A representation of a time dimension, which may contain
/// sentinel values.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct TimeDimensionFormat {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub start_time: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub end_time: Option<String>,
	pub data_type: TimeDataType,
	pub sentinel_values: Option<Vec<SentinelValue>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The specific data type of a time dimension.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
pub enum TimeDataType {
	ObservationalTimePeriod,
	StandardTimePeriod,
	BasicTimePeriod,
	GregorianTimePeriod,
	GregorianYear,
	GregorianYearMonth,
	GregorianDay,
	ReportingTimePeriod,
	ReportingYear,
	ReportingSemester,
	ReportingTrimester,
	ReportingQuarter,
	ReportingMonth,
	ReportingWeek,
	ReportingDay,
	DateTime,
	TimeRange,
}

impl TimeDataType {
	pub const fn is_reporting(&self) -> bool {
		matches!(
			self,
			Self::ReportingDay
				| Self::ReportingWeek
				| Self::ReportingMonth
				| Self::ReportingYear
				| Self::ReportingQuarter
				| Self::ReportingSemester
				| Self::ReportingTrimester
				| Self::ReportingTimePeriod
		)
	}

	pub const fn is_gregorian(&self) -> bool {
		matches!(
			self,
			Self::GregorianTimePeriod
				| Self::GregorianYear
				| Self::GregorianYearMonth
				| Self::GregorianDay
		)
	}
}

impl TryFrom<DataType> for TimeDataType {
	type Error = ();
	fn try_from(value: DataType) -> Result<Self, Self::Error> {
		match value {
			DataType::ObservationalTimePeriod => Ok(Self::ObservationalTimePeriod),
			DataType::StandardTimePeriod => Ok(Self::StandardTimePeriod),
			DataType::BasicTimePeriod => Ok(Self::BasicTimePeriod),
			DataType::GregorianTimePeriod => Ok(Self::GregorianTimePeriod),
			DataType::GregorianYear => Ok(Self::GregorianYear),
			DataType::GregorianYearMonth => Ok(Self::GregorianYearMonth),
			DataType::GregorianDay => Ok(Self::GregorianDay),
			DataType::ReportingTimePeriod => Ok(Self::ReportingTimePeriod),
			DataType::ReportingYear => Ok(Self::ReportingYear),
			DataType::ReportingSemester => Ok(Self::ReportingSemester),
			DataType::ReportingTrimester => Ok(Self::ReportingTrimester),
			DataType::ReportingQuarter => Ok(Self::ReportingQuarter),
			DataType::ReportingMonth => Ok(Self::ReportingMonth),
			DataType::ReportingWeek => Ok(Self::ReportingWeek),
			DataType::ReportingDay => Ok(Self::ReportingDay),
			DataType::DateTime => Ok(Self::DateTime),
			DataType::TimeRange => Ok(Self::TimeRange),
			_ => Err(()),
		}
	}
}

/// Specifies attribute values which have the same value
/// based on some common dimensionality.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct Group {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub group_dimensions: Option<Vec<String>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// Describes the structure of the measure descriptor
/// for a data structure definition.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
pub struct MeasureList {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub measures: Option<Vec<Measure>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A concept that quantifies the size, amount
/// or degree of something.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Measure {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	pub concept_identity: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub concept_roles: Option<Vec<String>>,
	pub local_representation: LocalRepresentation,
	pub usage: Usage,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A collection of metadata concepts and their structure
/// when used to collect or disseminate reference metadata.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct MetadataStructure {
	#[serde(flatten)]
	pub common: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_structure_components: Option<MetadataStructureComponents>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A set of components that makeup the metadata structure.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct MetadataStructureComponents {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_attribute_list: Option<MetadataAttributeList>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A set of metadata attributes that can be defined
/// as a hierarchy.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct MetadataAttributeList {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_attributes: Option<Vec<MetadataAttribute>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A metadata characteristic of an object or entity.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct MetadataAttribute {
	pub id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub annotations: Option<Vec<Annotation>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub links: Option<Vec<Link>>,
	pub concept_identity: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub local_representation: Option<MetadataAttributeRepresentation>,
	pub min_occurs: usize,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub max_occurs: Option<Occurrence>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_presentational: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_attributes: Option<Vec<MetadataAttribute>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The possible local representations of a metadata attribute
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub enum MetadataAttributeRepresentation {
	Enumeration(MetadataAttributeEnumeration),
	Format(MetadataAttributeFormat),
}

/// An enumeration-based local representation of a metadata attribute
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct MetadataAttributeEnumeration {
	pub enumeration: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub enumeration_format: Option<EnumerationFormat>,
}

/// A format-based local representation of a metadata attribute
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct MetadataAttributeFormat {
	pub format: Format,
}

/// The item scheme for a category.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct CategoryScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub categories: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a concept.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ConceptScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub concepts: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub core_representation: Option<CoreRepresentation>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub iso_concept_reference: Option<IsoConceptReference>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub parent: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A core representation for a concept.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct CoreRepresentation {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub enumeration: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub enumeration_format: Option<EnumerationFormat>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub format: Option<Format>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub min_occurs: Option<usize>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub max_occurs: Option<Occurrence>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// A reference to an ISO 11179 concept.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct IsoConceptReference {
	pub concept_agency: String,
	pub concept_id: String,
	pub concept_scheme_id: String,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a codelist.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Codelist {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub codes: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub parent: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a geography codelist.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct GeographyCodelist {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub geo_feature_set_codes: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a geographic grid codelist.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct GeoGridCodelist {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub geo_grid_codes: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for an agency.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct AgencyScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub agencies: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a data provider.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct DataProviderScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_providers: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a data consumer.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DataConsumerScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub data_consumers: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a metadata provider.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct MetadataProviderScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub metadata_providers: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for an organization unit.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct OrganizationUnitScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(alias = "organisationUnits")]
	pub organization_units: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The structure of data that will be provided for
/// different reference periods.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct Dataflow {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub structure: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for name personalization.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct NamePersonalizationScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(alias = "namePersonalisations")]
	pub name_personalizations: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a reporting taxonomy.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ReportingTaxonomy {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub reporting_categories: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// Describes what something (the source) falls under (the target).
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Categorization {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub source: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub target: Option<String>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a custom type.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct CustomTypeScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub custom_types: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a VTL (Validation and Transformation Language)
/// mapping.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct VtlMappingScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub vtl_mappings: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a ruleset.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RulesetScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub rulesets: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a transformation.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct TransformationScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub transformations: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

/// The item scheme for a user defined operator.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct UserDefinedOperatorsScheme {
	#[serde(flatten)]
	pub artefact: CommonArtefactType,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub is_partial: Option<bool>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub user_defined_operators: Option<Vec<Item>>,
	#[serde(skip_serializing_if = "Option::is_none")]
	#[serde(flatten)]
	pub other: Option<HashMap<String, Value>>,
}

impl_extendable!(
	StructureMessage,
	Data,
	Item,
	DataStructure,
	DataStructureComponents,
	AttributeList,
	Attribute,
	AttributeRelationshipDataflow,
	AttributeRelationshipDimensions,
	AttributeRelationshipGroups,
	AttributeRelationshipObservations,
	EnumerationFormat,
	Format,
	MetadataAttributeUsage,
	Dimension,
	TimeDimension,
	TimeDimensionFormat,
	Group,
	MeasureList,
	Measure,
	MetadataStructure,
	MetadataAttributeList,
	MetadataAttribute,
	CategoryScheme,
	ConceptScheme,
	CoreRepresentation,
	IsoConceptReference,
	Codelist,
	GeographyCodelist,
	GeoGridCodelist,
	AgencyScheme,
	DataProviderScheme,
	DataConsumerScheme,
	MetadataProviderScheme,
	OrganizationUnitScheme,
	Dataflow,
	NamePersonalizationScheme,
	ReportingTaxonomy,
	Categorization,
	CustomTypeScheme,
	VtlMappingScheme,
	RulesetScheme,
	TransformationScheme,
	UserDefinedOperatorsScheme,
);

impl_artefact! {
	CategoryScheme,
	ConceptScheme,
	Codelist,
	GeographyCodelist,
	GeoGridCodelist,
	AgencyScheme,
	DataProviderScheme,
	DataConsumerScheme,
	MetadataProviderScheme,
	OrganizationUnitScheme,
	Dataflow,
	NamePersonalizationScheme,
	ReportingTaxonomy,
	Categorization,
	CustomTypeScheme,
	VtlMappingScheme,
	RulesetScheme,
	TransformationScheme,
	UserDefinedOperatorsScheme,
}

impl_item_scheme! {
	(ConceptScheme, concepts),
	(CategoryScheme, categories),
	(Codelist, codes),
	(GeographyCodelist, geo_feature_set_codes),
	(GeoGridCodelist, geo_grid_codes),
	(AgencyScheme, agencies),
	(DataProviderScheme, data_providers),
	(DataConsumerScheme, data_consumers),
	(MetadataProviderScheme, metadata_providers),
	(OrganizationUnitScheme, organization_units),
	(NamePersonalizationScheme, name_personalizations),
	(ReportingTaxonomy, reporting_categories),
	(CustomTypeScheme, custom_types),
	(VtlMappingScheme, vtl_mappings),
	(RulesetScheme, rulesets),
	(TransformationScheme, transformations),
	(UserDefinedOperatorsScheme, user_defined_operators),
}