1use std::collections::HashMap;
2
3pub type FieldName = String;
4pub type FieldMap = HashMap<FieldName, FieldOptions>;
5
6#[derive(Debug, Clone, Default)]
7pub enum FieldType {
8 #[default]
9 String,
10 I32,
11 I64,
12 U32,
13 U64,
14 F32,
15 F64,
16 Bool,
17 Document(String),
18 Enumerate(String),
19 Array(Vec<FieldType>),
20}
21
22#[derive(Debug, Clone)]
23pub enum FieldValue {
24 String(String),
25 I32(i32),
26 I64(i64),
27 U32(u32),
28 U64(u64),
29 F32(f32),
30 F64(f64),
31 Bool(bool),
32 Document(DocumentName),
33 Enumerate(EnumerateName),
34 Array(Vec<FieldValue>),
35 Raw(String),
37}
38
39#[derive(Debug, Clone, Default)]
40pub struct FieldOptions {
41 pub comments: Option<String>,
42 pub r#type: FieldType,
43 pub name: Option<String>,
44 pub required: Option<bool>,
45 pub min_length: Option<u32>,
46 pub max_length: Option<u32>,
47 pub min_value: Option<FieldValue>,
48 pub max_value: Option<FieldValue>,
49 pub regex: Option<String>,
50 pub default: Option<FieldValue>,
51}
52
53pub type DocumentName = String;
54pub type DocumentMap = HashMap<DocumentName, Document>;
55
56#[derive(Clone, Debug, Default)]
57pub struct Document {
58 pub name: DocumentName,
59 pub options: DocumentOptions,
60 pub fields: FieldMap,
61}
62
63#[derive(Debug, Clone, Default)]
64pub struct DocumentOptions {
65 pub name: Option<String>,
67 pub root: Option<bool>,
69}
70
71pub type EnumerateName = String;
72pub type EnumMap = HashMap<EnumerateName, Enumerable>;
73
74#[derive(Clone, Debug, Default)]
75pub struct Enumerable {
76 pub name: EnumerateName,
77 pub options: EnumOptions,
78 pub fields: FieldMap,
79}
80
81#[derive(Clone, Debug, Default)]
82pub struct EnumOptions {
83 pub comments: Option<String>,
84 pub name: Option<String>,
85}