1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use crate::model::*;
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum UniversalStructField {
Basic(BasicType),
Struct(UniversalStructHandle),
}
pub type UniversalStructHandle = Handle<Struct<UniversalStructField, Unvalidated>>;
impl StructFieldType for UniversalStructField {
fn create_struct_type(
v: Handle<Struct<UniversalStructField, Unvalidated>>,
) -> StructType<Unvalidated> {
StructType::Universal(v)
}
}
impl InitializerValidator for UniversalStructField {
fn validate_default_value(
&self,
value: &InitializerDefault,
) -> BindResult<ValidatedDefaultValue> {
match self {
UniversalStructField::Basic(x) => x.validate_default_value(value),
UniversalStructField::Struct(x) => x.validate_default_value(value),
}
}
}
impl From<Primitive> for UniversalStructField {
fn from(x: Primitive) -> Self {
Self::Basic(x.into())
}
}
impl From<BasicType> for UniversalStructField {
fn from(x: BasicType) -> Self {
UniversalStructField::Basic(x)
}
}
impl From<DurationType> for UniversalStructField {
fn from(x: DurationType) -> Self {
BasicType::Duration(x).into()
}
}
impl From<Handle<Enum<Unvalidated>>> for UniversalStructField {
fn from(x: Handle<Enum<Unvalidated>>) -> Self {
Self::Basic(BasicType::Enum(x))
}
}
impl From<UniversalStructHandle> for UniversalStructField {
fn from(x: UniversalStructHandle) -> Self {
UniversalStructField::Struct(x)
}
}