sbrd_gen/
generator_type.rs

1#![deny(missing_debug_implementations)]
2//! Module for type of generator
3
4use serde::{Deserialize, Serialize};
5
6/// Type of generator
7#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone, Copy)]
8#[serde(rename_all = "kebab-case")]
9pub enum GeneratorType {
10    //
11    // build string
12    //
13    /// Type for [`DuplicatePermutationGenerator`]
14    ///
15    /// [`DuplicatePermutationGenerator`]: ../generator/build_string/struct.DuplicatePermutationGenerator.html
16    DuplicatePermutation,
17    /// Type for [`FormatGenerator`]
18    ///
19    /// [`FormatGenerator`]: ../generator/build_string/struct.FormatGenerator.html
20    Format,
21
22    //
23    // distribution
24    //
25    /// Type for [`NormalGenerator`]
26    ///
27    /// [`NormalGenerator`]: ../generator/distribution/struct.NormalGenerator.html
28    DistNormal,
29
30    //
31    // evaluate
32    //
33    /// Type for [`EvalGenerator`] as  [`DataValue::Int`]
34    ///
35    /// [`EvalGenerator`]: ../generator/evaluate/struct.EvalGenerator.html
36    /// [`DataValue::Int`]: ../value/enum.DataValue.html#variant.Int
37    EvalInt,
38    /// Type for [`EvalGenerator`] as  [`DataValue::Real`]
39    ///
40    /// [`EvalGenerator`]: ../generator/evaluate/struct.EvalGenerator.html
41    /// [`DataValue::Real`]: ../value/enum.DataValue.html#variant.Real
42    EvalReal,
43    /// Type for [`EvalGenerator`] as  [`DataValue::Bool`]
44    ///
45    /// [`EvalGenerator`]: ../generator/evaluate/struct.EvalGenerator.html
46    /// [`DataValue::Bool`]: ../value/enum.DataValue.html#variant.Bool
47    EvalBool,
48    /// Type for [`EvalGenerator`] as  [`DataValue::String`]
49    ///
50    /// [`EvalGenerator`]: ../generator/evaluate/struct.EvalGenerator.html
51    /// [`DataValue::String`]: ../value/enum.DataValue.html#variant.String
52    EvalString,
53
54    //
55    // incremental
56    //
57    /// Type for [`IncrementIdGenerator`]
58    ///
59    /// [`IncrementIdGenerator`]: ../generator/incremental/struct.IncrementIdGenerator.html
60    IncrementId,
61
62    //
63    // primitive
64    //
65    /// Type for [`IntGenerator`]
66    ///
67    /// [`IntGenerator`]: ../generator/primitive/struct.IntGenerator.html
68    Int,
69    /// Type for [`RealGenerator`]
70    ///
71    /// [`RealGenerator`]: ../generator/primitive/struct.RealGenerator.html
72    Real,
73    /// Type for [`BoolGenerator`]
74    ///
75    /// [`BoolGenerator`]: ../generator/primitive/struct.BoolGenerator.html
76    Bool,
77    /// Type for [`DateTimeGenerator`]
78    ///
79    /// [`DateTimeGenerator`]: ../generator/primitive/struct.DateTimeGenerator.html
80    DateTime,
81    /// Type for [`DateGenerator`]
82    ///
83    /// [`DateGenerator`]: ../generator/primitive/struct.DateGenerator.html
84    Date,
85    /// Type for [`TimeGenerator`]
86    ///
87    /// [`TimeGenerator`]: ../generator/primitive/struct.TimeGenerator.html
88    Time,
89    /// Type for [`AlwaysNullGenerator`]
90    ///
91    /// [`AlwaysNullGenerator`]: ../generator/primitive/struct.AlwaysNullGenerator.html
92    AlwaysNull,
93
94    //
95    // randomize children
96    //
97    /// Type for [`CaseWhenGenerator`]
98    ///
99    /// [`CaseWhenGenerator`]: ../generator/random_children/struct.CaseWhenGenerator.html
100    CaseWhen,
101    /// Type for [`RandomChildGenerator`]
102    ///
103    /// [`RandomChildGenerator`]: ../generator/random_children/struct.RandomChildGenerator.html
104    RandomChild,
105
106    //
107    // randomize values
108    //
109    /// Type for [`SelectGenerator`] as  [`DataValue::Int`]
110    ///
111    /// [`SelectGenerator`]: ../generator/random_values/struct.SelectGenerator.html
112    /// [`DataValue::Int`]: ../value/enum.DataValue.html#variant.Int
113    SelectInt,
114    /// Type for [`SelectGenerator`] as  [`DataValue::Real`]
115    ///
116    /// [`SelectGenerator`]: ../generator/random_values/struct.SelectGenerator.html
117    /// [`DataValue::Real`]: ../value/enum.DataValue.html#variant.Real
118    SelectReal,
119    /// Type for [`SelectGenerator`] as  [`DataValue::String`]
120    ///
121    /// [`SelectGenerator`]: ../generator/random_values/struct.SelectGenerator.html
122    /// [`DataValue::String`]: ../value/enum.DataValue.html#variant.String
123    SelectString,
124    /// Type for [`GetValueAtGenerator`] as  [`DataValue::Int`]
125    ///
126    /// [`GetValueAtGenerator`]: ../generator/random_values/struct.GetValueAtGenerator.html
127    /// [`DataValue::Int`]: ../value/enum.DataValue.html#variant.Int
128    GetIntValueAt,
129    /// Type for [`GetValueAtGenerator`] as  [`DataValue::Real`]
130    ///
131    /// [`GetValueAtGenerator`]: ../generator/random_values/struct.GetValueAtGenerator.html
132    /// [`DataValue::Real`]: ../value/enum.DataValue.html#variant.Real
133    GetRealValueAt,
134    /// Type for [`GetValueAtGenerator`] as  [`DataValue::String`]
135    ///
136    /// [`GetValueAtGenerator`]: ../generator/random_values/struct.GetValueAtGenerator.html
137    /// [`DataValue::String`]: ../value/enum.DataValue.html#variant.String
138    GetStringValueAt,
139    /// Type for [`GetValueIndexGenerator`]
140    ///
141    /// [`GetValueIndexGenerator`]: ../generator/random_values/struct.GetValueIndexGenerator.html
142    GetValueIndex,
143}
144
145impl std::fmt::Display for GeneratorType {
146    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
147        let s = serde_yaml::to_string(&self)
148            .unwrap_or_else(|e| panic!("Fail serialize {:?} with error {}.", &self, e));
149        write!(f, "{}", s)
150    }
151}