xsd_parser/pipeline/generator/data/
mod.rs1mod complex;
2mod dynamic;
3mod enumeration;
4mod reference;
5mod simple;
6mod type_;
7mod union;
8
9use proc_macro2::TokenStream;
10use quote::quote;
11
12use crate::models::{
13 data::{BuildInData, CustomData, Occurs},
14 meta::{BuildInMeta, CustomMeta},
15};
16
17impl<'types> BuildInData<'types> {
18 fn new(meta: &'types BuildInMeta) -> Self {
19 Self { meta }
20 }
21}
22
23impl<'types> CustomData<'types> {
24 fn new(meta: &'types CustomMeta) -> Self {
25 Self { meta }
26 }
27}
28
29impl Occurs {
30 #[must_use]
39 pub fn make_type(self, ident: &TokenStream, need_indirection: bool) -> Option<TokenStream> {
40 match self {
41 Self::None => None,
42 Self::Single if need_indirection => Some(quote! { Box<#ident> }),
43 Self::Single => Some(quote! { #ident }),
44 Self::Optional if need_indirection => Some(quote! { Option<Box<#ident>> }),
45 Self::Optional => Some(quote! { Option<#ident> }),
46 Self::DynamicList => Some(quote! { Vec<#ident> }),
47 Self::StaticList(sz) if need_indirection => Some(quote! { [Box<#ident>; #sz] }),
48 Self::StaticList(sz) => Some(quote! { [#ident; #sz] }),
49 }
50 }
51}