pub mod parser;
use std::collections::{HashMap, HashSet};
use crate::Spanned;
use crate::ron::RonValue;
#[derive(Debug, Clone, PartialEq)]
pub struct EnumDef {
pub name: String,
pub variants: HashMap<String, Option<SchemaType>>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum SchemaType {
String,
Integer,
Float,
Bool,
Option(Box<SchemaType>),
List(Box<SchemaType>),
EnumRef(String),
AliasRef(String),
Map(Box<SchemaType>, Box<SchemaType>),
Tuple(Vec<SchemaType>),
Struct(StructDef),
}
#[derive(Debug, Clone, PartialEq)]
pub struct FieldDef {
pub name: Spanned<String>,
pub type_: Spanned<SchemaType>,
pub default: Option<Spanned<RonValue>>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct StructDef {
pub fields: Vec<FieldDef>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Schema {
pub root: StructDef,
pub enums: HashMap<String, EnumDef>,
pub aliases: HashMap<String, Spanned<SchemaType>>,
}