1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
use serde::Deserialize; #[derive(Deserialize, Debug, Clone)] pub struct Node { pub struct_name: String, pub str_type: String, pub filename: String, pub fields: Vec<Field>, pub comment: String, } #[derive(Debug, Clone, Deserialize)] pub struct Field { pub field_name: String, pub field_type: FieldType, pub always_print: bool, pub comment: String, } #[derive(PartialEq, Clone, Deserialize, Debug)] pub enum FieldType { Node, Nodes, MaybeNode, Loc, MaybeLoc, Str, MaybeStr, Chars, StringValue, U8, Usize, RawString, RegexOptions, } impl FieldType { pub fn has_reference_to_node(&self) -> bool { matches!( self, Self::Node | Self::Nodes | Self::MaybeNode | Self::RegexOptions ) } pub fn has_reference_to_loc(&self) -> bool { matches!(self, FieldType::Loc | FieldType::MaybeLoc) } }