1pub mod builders;
2pub mod declarations;
3
4pub use declarations::Declarations;
5
6#[derive(Debug, Clone)]
7pub enum TPrimitive {
8 String,
9 Ti64,
10 Tf64,
11 Ti32,
12 Tu32,
13 Tusize,
14 Tbool,
15 TGeneric(TGeneric),
16 TReference(TReference),
17 THardcoded(&'static str),
18 TDifferentPerLanguage {
19 hack: Box<TPrimitive>,
20 rust: Box<TPrimitive>,
21 flow: Box<TPrimitive>,
22 },
23 TVec(Box<TVec>),
24 TMap(Box<TMap>),
25 TOption(Box<TOption>),
26}
27
28#[derive(Debug, Clone)]
29pub struct TReference {
30 name: &'static str,
32 pub generic_params: Vec<TGeneric>,
33}
34
35impl TReference {
36 pub fn get_name(&self) -> &'static str {
37 self.name
38 }
39
40 pub fn primitive(&self) -> TPrimitive {
41 TPrimitive::TReference(self.clone())
42 }
43}
44
45#[derive(Debug, Clone)]
46pub enum TOption {
47 TMap(TMap),
48 TPrimitive(TPrimitive),
49 TSet(TSet),
50 TVec(TVec),
51 TTuple(TTuple),
52}
53
54#[derive(Debug, Clone)]
55pub enum TVec {
56 TPrimitive(TPrimitive),
57}
58
59#[derive(Debug, Clone)]
60pub enum TSet {
61 TPrimitive(TPrimitive),
62}
63
64#[derive(Debug, Clone, Copy)]
65pub enum TMapType {
66 Hash,
67 BTree,
68}
69
70#[derive(Debug, Clone)]
71pub struct TMap {
72 pub key: TPrimitive,
73 pub value: TMapValue,
74 pub t: TMapType,
75}
76
77#[derive(Debug, Clone)]
78pub enum TGeneric {
79 TDefinition {
82 name: &'static str,
83 bounds: Option<&'static str>,
84 },
85 TReference(TReference),
87}
88
89#[derive(Debug, Clone)]
90pub enum TMapValue {
91 TPrimitive(TPrimitive),
92 TSet(TSet),
93}
94
95#[derive(Debug, Clone)]
96pub struct TTuple {
97 pub items: Vec<TupleItem>,
98}
99
100#[derive(Debug, Clone)]
101pub enum TupleItem {
102 TPrimitive(TPrimitive),
103 TOption(TOption),
104}
105
106#[derive(Debug, Clone)]
107pub struct TypeDeclaration {
108 pub name: &'static str,
109 pub docs: &'static str,
110 pub value: DeclarationValue,
111 pub config: Vec<TypeDeclarationConfig>,
112 pub generic_params: Vec<TGeneric>,
113}
114
115#[derive(Debug, Clone, Copy)]
116pub enum TypeDeclarationConfig {
117 RustAttribute(&'static str),
118}
119
120#[derive(Debug, Clone)]
121pub enum DeclarationValue {
122 TEnum(TEnum),
123 TSimpleEnum(TSimpleEnum),
124 TMap(Box<TMap>),
125 TVec(Box<TVec>),
126 TOption(Box<TOption>),
127 TPrimitive(TPrimitive),
128 TStruct(TStruct),
129 TTuple(TTuple),
130 Docs,
131 CodeBlock(CodeBlock),
132}
133
134#[derive(Debug, Clone)]
135pub enum CodeBlock {
136 Rust(Vec<&'static str>),
137 Hack(Vec<&'static str>),
138 Flow(Vec<&'static str>),
139}
140
141#[derive(Debug, Clone)]
142pub struct TStruct {
143 pub fields: Vec<StructField>,
144}
145
146#[derive(Debug, Clone)]
147pub struct StructField {
148 pub name: &'static str,
149 pub docs: &'static str,
150 pub field_type: StructFieldType,
151 pub config: Vec<StructFieldConfig>,
152}
153
154#[derive(Debug, Clone)]
155pub enum StructFieldConfig {
156 RustAttribute(&'static str),
157 RustOverride(&'static str),
158}
159
160#[derive(Debug, Clone)]
161pub enum StructFieldType {
162 TMap(TMap),
163 TSet(TSet),
164 TOption(TOption),
165 TPrimitive(TPrimitive),
166 TTuple(TTuple),
167 TVec(TVec),
168}
169
170#[derive(Debug, Clone)]
171pub struct TEnum {
172 pub variants: Vec<EnumVariant>,
173}
174
175#[derive(Debug, Clone)]
176pub struct EnumVariant {
177 pub name: &'static str,
178 pub docs: &'static str,
179 pub variant_type: EnumVariantType,
180}
181
182#[derive(Debug, Clone)]
183pub enum EnumVariantType {
184 TStruct(TStruct),
202 TPrimitive(TPrimitive),
203}
204
205#[derive(Debug, Clone)]
211pub struct TSimpleEnum {
212 pub variants: Vec<&'static str>,
213}