xsd_parser/models/data/dynamic.rs
1use std::borrow::Cow;
2
3use proc_macro2::{Ident as Ident2, Literal};
4
5use crate::models::{data::PathData, meta::DynamicMeta, TypeIdent};
6
7/// Contains additional information for the rendering process of a
8/// [`MetaTypeVariant::Dynamic`](crate::models::meta::MetaTypeVariant::Dynamic)
9/// type.
10#[derive(Debug)]
11pub struct DynamicData<'types> {
12 /// Reference to the original type information.
13 pub meta: Cow<'types, DynamicMeta>,
14
15 /// The identifier of the rendered type.
16 pub type_ident: Ident2,
17
18 /// The identifier of the trait that needs to be implemented
19 /// by the derived types.
20 pub trait_ident: Ident2,
21
22 /// Identifier of the deserializer for this type.
23 pub deserializer_ident: Ident2,
24
25 /// List of additional traits that need to be implemented by the derived
26 /// types (if this type was inherited from another dynamic type).
27 pub sub_traits: Option<Vec<PathData>>,
28
29 /// List of derived types.
30 pub derived_types: Vec<DerivedType>,
31}
32
33/// Represents a derived type used by [`DynamicData`]
34#[derive(Debug)]
35pub struct DerivedType {
36 /// Identifier of the derived type.
37 pub ident: TypeIdent,
38
39 /// Name of the derived type as byte string literal.
40 pub b_name: Literal,
41
42 /// The actual target type of this derived type information.
43 pub target_type: PathData,
44
45 /// Name of the variant used for this derived type information.
46 pub variant_ident: Ident2,
47}