rust_code_visualizer/
structures.rs

1#[derive(Debug, Eq, PartialEq)]
2pub enum Element {
3    Struct(StructElement),
4    Enum(EnumElement),
5}
6
7#[derive(Debug, Eq, PartialEq)]
8pub struct StructElement {
9    pub name: String,
10    pub fields: Vec<Field>,
11}
12
13#[derive(Debug, Eq, PartialEq)]
14pub struct EnumElement {
15    pub name: String,
16    pub variants: Vec<Variant>,
17}
18
19#[derive(Debug, Eq, PartialEq)]
20pub struct Variant {
21    pub name: String,
22    pub fields: Vec<Field>,
23}
24
25#[derive(Debug, Eq, PartialEq)]
26pub enum Type {
27    Simple(String),
28    Vec(Box<Type>),
29    Tuple(Vec<Type>),
30    Other(Box<Type>),
31}
32
33#[derive(Debug, Eq, PartialEq)]
34pub struct Field {
35    /// Can be option because of enums:
36    /// ```no_run
37    /// enum TestEnum {
38    ///     Variant1(u32)
39    /// }
40    /// ```
41    /// In that case name will placed in  Variant struct and Field.name will be empty
42    pub name: Option<String>,
43    pub ty: Type,
44}