type_reflect_core/
type_description.rs1use crate::{Inflectable, Inflection};
2
3#[derive(Clone, Debug)]
4pub struct NamedType {
5 pub name: String,
6 pub generic_args: Vec<Box<Type>>,
7}
8
9#[derive(Clone, Debug)]
10pub enum TransparentTypeCase {
11 Box,
12 Rc,
13 Arc,
14}
15
16#[derive(Clone, Debug)]
17pub struct TransparentType {
18 pub case: TransparentTypeCase,
19 pub type_: Box<Type>,
20}
21
22#[derive(Clone, Debug)]
23pub enum Type {
24 Named(NamedType),
25 String,
26 Int,
27 UnsignedInt,
28 Float,
29 Boolean,
30 Transparent(TransparentType),
31 Option(Box<Type>),
32 Array(Box<Type>),
33 Map { key: Box<Type>, value: Box<Type> },
34}
35
36#[derive(Clone, Debug)]
37pub struct NamedField {
38 pub name: String,
39 pub type_: Type,
40}
41
42#[derive(Clone, Debug)]
43pub struct EnumCase {
44 pub name: String,
45 pub type_: TypeFieldsDefinition,
46 pub inflection: Inflection,
47}
48
49impl EnumCase {
50 pub fn name_with_inflection(&self) -> String {
51 self.name.inflect(self.inflection)
52 }
53}
54
55#[derive(Clone, Debug)]
61pub enum TypeFieldsDefinition {
62 Unit,
66 Tuple(Vec<Type>),
70 Named(Vec<NamedField>),
74}
75
76#[derive(Clone, Debug)]
77pub enum EnumType {
78 Simple,
79 Complex {
80 case_key: String,
81 content_key: Option<String>,
82 },
83 Untagged,
84}
85
86