xsd_parser/models/data/enumeration.rs
1use proc_macro2::{Ident as Ident2, Literal, TokenStream};
2
3use crate::models::{
4 data::{ConstrainsData, PathData},
5 meta::{EnumerationMeta, EnumerationMetaVariant},
6};
7
8/// Contains additional information for the rendering process of a
9/// [`MetaTypeVariant::Enumeration`](crate::models::meta::MetaTypeVariant::Enumeration)
10/// type.
11#[derive(Debug)]
12pub struct EnumerationData<'types> {
13 /// Reference to the original type information.
14 pub meta: &'types EnumerationMeta,
15
16 /// Code generator data for the constrains of the type.
17 pub constrains: ConstrainsData<'types>,
18
19 /// The identifier of the rendered type.
20 pub type_ident: Ident2,
21
22 /// List of variants of this enumeration.
23 pub variants: Vec<EnumerationTypeVariant<'types>>,
24
25 /// List of traits that needs to be implemented by this type.
26 pub trait_impls: Vec<TokenStream>,
27}
28
29/// Represents a enumeration variant used by [`EnumerationData`].
30#[derive(Debug)]
31pub struct EnumerationTypeVariant<'types> {
32 /// Reference to the original type information.
33 pub meta: &'types EnumerationMetaVariant,
34
35 /// Name of the attribute as string.
36 pub s_name: String,
37
38 /// Name of the attribute as byte string literal.
39 pub b_name: Literal,
40
41 /// Name of this variant.
42 pub variant_ident: Ident2,
43
44 /// Target type of this variant.
45 pub target_type: Option<PathData>,
46
47 /// Additional attributes that will be added to the variant.
48 pub extra_attributes: Vec<TokenStream>,
49}