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::*;
#[derive(Clone, Debug)]
pub enum TypeKind {
/// A homogeneous array of a possibly known size
Array {
/// Type of items this array accepts
ty: Box<Type>,
/// An optional hint about the array's expected size
size: Option<usize>,
},
/// `true` / `false`
Bool,
/// An algebraic data type
Enum {
/// The way enum should be serialized
tag: Tag,
/// All enum's variants
variants: Vec<Variant>,
},
/// A floating-point number
Float,
/// An integer number
Integer,
/// A homogeneous map
Map { key: Box<Type>, value: Box<Type> },
/// `Option<Ty>`
Optional { ty: Box<Type> },
/// A UTF-8 string
String,
/// A structure
Struct {
fields: Fields,
/// Whether this type should behave as a passthrough-wrapper.
/// Corresponds to `#[serde(transparent)]`.
transparent: bool,
},
/// A heterogeneous list of an up-front known size
Tuple { fields: Vec<Type> },
}
impl From<Fields> for TypeKind {
fn from(fields: Fields) -> Self {
TypeKind::Struct {
fields,
transparent: false,
}
}
}