doku/objects/
field.rs

1use crate::*;
2
3#[derive(Clone, Debug)]
4pub struct Field {
5    /// Type of this field
6    pub ty: Type,
7
8    /// Whether this field should get flattened (i.e. `#[serde(flatten)]`)
9    pub flattened: bool,
10
11    /// The serde aliases for this field
12    pub aliases: &'static [&'static str],
13}
14
15impl From<Type> for Field {
16    fn from(ty: Type) -> Self {
17        Self {
18            ty,
19            flattened: false,
20            aliases: &[],
21        }
22    }
23}
24
25impl From<TypeKind> for Field {
26    fn from(kind: TypeKind) -> Self {
27        let ty: Type = kind.into();
28        ty.into()
29    }
30}
31
32impl From<Fields> for Field {
33    fn from(fields: Fields) -> Self {
34        let kind: TypeKind = fields.into();
35        kind.into()
36    }
37}