pub mod builders;
pub mod declarations;
pub use declarations::Declarations;
#[derive(Debug, Clone)]
pub enum TPrimitive {
String,
Ti64,
Tf64,
Ti32,
Tu32,
Tusize,
Tbool,
TGeneric(TGeneric),
TReference(TReference),
THardcoded(&'static str),
TDifferentPerLanguage {
hack: Box<TPrimitive>,
rust: Box<TPrimitive>,
flow: Box<TPrimitive>,
},
TVec(Box<TVec>),
TMap(Box<TMap>),
TOption(Box<TOption>),
}
#[derive(Debug, Clone)]
pub struct TReference {
name: &'static str,
pub generic_params: Vec<TGeneric>,
}
impl TReference {
pub fn get_name(&self) -> &'static str {
self.name
}
pub fn primitive(&self) -> TPrimitive {
TPrimitive::TReference(self.clone())
}
}
#[derive(Debug, Clone)]
pub enum TOption {
TMap(TMap),
TPrimitive(TPrimitive),
TSet(TSet),
TVec(TVec),
TTuple(TTuple),
}
#[derive(Debug, Clone)]
pub enum TVec {
TPrimitive(TPrimitive),
}
#[derive(Debug, Clone)]
pub enum TSet {
TPrimitive(TPrimitive),
}
#[derive(Debug, Clone, Copy)]
pub enum TMapType {
Hash,
BTree,
}
#[derive(Debug, Clone)]
pub struct TMap {
pub key: TPrimitive,
pub value: TMapValue,
pub t: TMapType,
}
#[derive(Debug, Clone)]
pub enum TGeneric {
TDefinition {
name: &'static str,
bounds: Option<&'static str>,
},
TReference(TReference),
}
#[derive(Debug, Clone)]
pub enum TMapValue {
TPrimitive(TPrimitive),
TSet(TSet),
}
#[derive(Debug, Clone)]
pub struct TTuple {
pub items: Vec<TupleItem>,
}
#[derive(Debug, Clone)]
pub enum TupleItem {
TPrimitive(TPrimitive),
TOption(TOption),
}
#[derive(Debug, Clone)]
pub struct TypeDeclaration {
pub name: &'static str,
pub docs: &'static str,
pub value: DeclarationValue,
pub config: Vec<TypeDeclarationConfig>,
pub generic_params: Vec<TGeneric>,
}
#[derive(Debug, Clone, Copy)]
pub enum TypeDeclarationConfig {
RustAttribute(&'static str),
}
#[derive(Debug, Clone)]
pub enum DeclarationValue {
TEnum(TEnum),
TSimpleEnum(TSimpleEnum),
TMap(Box<TMap>),
TVec(Box<TVec>),
TOption(Box<TOption>),
TPrimitive(TPrimitive),
TStruct(TStruct),
TTuple(TTuple),
Docs,
CodeBlock(CodeBlock),
}
#[derive(Debug, Clone)]
pub enum CodeBlock {
Rust(Vec<&'static str>),
Hack(Vec<&'static str>),
Flow(Vec<&'static str>),
}
#[derive(Debug, Clone)]
pub struct TStruct {
pub fields: Vec<StructField>,
}
#[derive(Debug, Clone)]
pub struct StructField {
pub name: &'static str,
pub docs: &'static str,
pub field_type: StructFieldType,
pub config: Vec<StructFieldConfig>,
}
#[derive(Debug, Clone)]
pub enum StructFieldConfig {
RustAttribute(&'static str),
RustOverride(&'static str),
}
#[derive(Debug, Clone)]
pub enum StructFieldType {
TMap(TMap),
TSet(TSet),
TOption(TOption),
TPrimitive(TPrimitive),
TTuple(TTuple),
TVec(TVec),
}
#[derive(Debug, Clone)]
pub struct TEnum {
pub variants: Vec<EnumVariant>,
}
#[derive(Debug, Clone)]
pub struct EnumVariant {
pub name: &'static str,
pub docs: &'static str,
pub variant_type: EnumVariantType,
}
#[derive(Debug, Clone)]
pub enum EnumVariantType {
TStruct(TStruct),
TPrimitive(TPrimitive),
}
#[derive(Debug, Clone)]
pub struct TSimpleEnum {
pub variants: Vec<&'static str>,
}