#[derive(Debug)]
pub struct Struct {
pub name: String,
pub fields: Vec<Field>,
}
#[derive(Debug)]
pub struct Field {
pub name: String,
pub serialized_name: String,
pub ty: FieldType,
}
#[derive(Debug)]
pub struct NewType {
pub name: String,
pub inner: FieldType,
}
#[derive(Debug)]
pub struct Alias {
pub name: String,
pub inner: FieldType,
}
#[derive(Debug)]
pub struct Enum {
pub name: String,
pub variants: Vec<EnumVariant>,
}
#[derive(Debug)]
pub struct EnumVariant {
pub name: String,
pub serialized_name: String,
}
#[derive(Debug)]
pub struct Union {
pub name: String,
pub representation: UnionRepresentation,
pub variants: Vec<UnionVariant>,
}
#[derive(Debug, PartialEq, Eq)]
pub struct UnionVariant {
pub name: Option<String>,
pub ty: FieldType,
pub serialized_name: String,
}
#[derive(Debug)]
pub enum UnionRepresentation {
AdjacentlyTagged {
tag: String,
content: String,
},
InternallyTagged {
tag: String,
},
ExternallyTagged,
Untagged,
}
#[derive(Debug, PartialEq, Eq)]
pub enum FieldType {
Optional(Box<FieldType>),
List(Box<FieldType>),
Map {
key: Box<FieldType>,
value: Box<FieldType>,
},
Named(TypeRef),
Primitive(Primitive),
}
#[derive(Debug, PartialEq, Eq)]
pub enum Primitive {
String,
Float,
Int,
Bool,
Time,
}
#[derive(Debug, PartialEq, Eq)]
pub struct TypeRef {
pub(crate) name: String,
}
impl TypeRef {
pub(crate) fn name(&self) -> &str {
&self.name
}
}