doku/objects/type_kind.rs
1use crate::*;
2
3#[derive(Clone, Debug)]
4pub enum TypeKind {
5 /// A homogeneous array of a possibly known size
6 Array {
7 /// Type of items this array accepts
8 ty: Box<Type>,
9
10 /// An optional hint about the array's expected size
11 size: Option<usize>,
12 },
13
14 /// `true` / `false`
15 Bool,
16
17 /// An algebraic data type
18 Enum {
19 /// The way enum should be serialized
20 tag: Tag,
21
22 /// All enum's variants
23 variants: Vec<Variant>,
24 },
25
26 /// A floating-point number
27 Float,
28
29 /// An integer number
30 Integer,
31
32 /// A homogeneous map
33 Map { key: Box<Type>, value: Box<Type> },
34
35 /// `Option<Ty>`
36 Optional { ty: Box<Type> },
37
38 /// A UTF-8 string
39 String,
40
41 /// A structure
42 Struct {
43 fields: Fields,
44
45 /// Whether this type should behave as a passthrough-wrapper.
46 /// Corresponds to `#[serde(transparent)]`.
47 transparent: bool,
48 },
49
50 /// A heterogeneous list of an up-front known size
51 Tuple { fields: Vec<Type> },
52}
53
54impl From<Fields> for TypeKind {
55 fn from(fields: Fields) -> Self {
56 TypeKind::Struct {
57 fields,
58 transparent: false,
59 }
60 }
61}