62 lines
1.1 KiB
Rust
Raw Normal View History

2023-09-27 17:51:03 +02:00
#[derive(Debug, Clone)]
pub enum Types {
String,
Bool,
F32, F64,
I8, I16, I32, I64,
U8, U16, U32, U64,
Named(String)
}
#[derive(Debug, Clone, Default)]
pub struct EnumTy {
pub name: String,
pub values: Vec<(String, usize)>
}
#[derive(Debug, Clone)]
pub struct FieldTy {
pub name: String,
pub ty: Types,
pub optional: bool,
pub array: bool
}
#[derive(Debug, Clone, Default)]
pub struct StructTy {
pub name: String,
pub fields: Vec<FieldTy>
}
#[derive(Debug, Clone, Default)]
pub struct MethodTy {
pub name: String,
pub args: Vec<FieldTy>,
pub ret: Option<FieldTy>,
pub ret_stream: bool
}
#[derive(Debug, Clone, Default)]
pub struct ServiceTy {
pub name: String,
pub methods: Vec<MethodTy>
}
#[derive(Debug, Clone, Default)]
pub struct RPC {
pub enums: Vec<EnumTy>,
pub structs: Vec<StructTy>,
pub services: Vec<ServiceTy>
}
impl FieldTy {
pub fn new(ty: Types) -> Self {
Self {
name: String::new(),
ty,
optional: false,
array: false
}
}
}