xsd_parser/models/data/types.rs
1use std::ops::Deref;
2
3use indexmap::IndexMap;
4
5use crate::models::Ident;
6use crate::pipeline::generator::MetaData as GeneratorMetaData;
7
8use super::DataType;
9
10/// Holds all generated Rust data types along with associated metadata.
11///
12/// This structure is produced by the [`Generator`](crate::Generator) after processing
13/// the intermediate [`MetaTypes`](crate::models::meta::MetaTypes). It serves as the
14/// final intermediate representation used in the rendering stage to output Rust code.
15///
16/// The `items` map contains type-safe, idiomatic Rust representations for each schema
17/// element, type, or attribute group encountered.
18///
19/// The `meta` field holds generator-specific configuration and state, such as flags,
20/// postfix rules, and user-defined overrides, which influence the structure and naming
21/// of generated code.
22#[derive(Debug)]
23pub struct DataTypes<'types> {
24 /// Meta types and information from the generator process
25 pub meta: GeneratorMetaData<'types>,
26
27 /// Map of the different types.
28 pub items: IndexMap<Ident, DataType<'types>>,
29}
30
31impl<'types> DataTypes<'types> {
32 pub(crate) fn new(meta: GeneratorMetaData<'types>) -> Self {
33 let items = IndexMap::default();
34
35 Self { meta, items }
36 }
37}
38
39impl<'types> Deref for DataTypes<'types> {
40 type Target = GeneratorMetaData<'types>;
41
42 fn deref(&self) -> &Self::Target {
43 &self.meta
44 }
45}