gesha_rust_types/
enum_def.rs

1use crate::{Definition, EnumMacroForFrom, EnumMacroForSerde, EnumVariant, TypeHeader};
2
3#[derive(Clone, Debug, PartialEq)]
4pub struct EnumDef {
5    pub header: TypeHeader,
6    pub variants: Vec<EnumVariant>,
7    pub macro_for_serde: Option<EnumMacroForSerde>,
8    pub macro_for_from: Option<EnumMacroForFrom>,
9    _hide_default_constructor: bool,
10}
11
12impl EnumDef {
13    pub fn new(
14        header: TypeHeader,
15        variants: Vec<EnumVariant>,
16        macro_for_serde: Option<EnumMacroForSerde>,
17        macro_for_from: Option<EnumMacroForFrom>,
18    ) -> Self {
19        Self {
20            header,
21            variants,
22            macro_for_serde,
23            macro_for_from,
24            _hide_default_constructor: true,
25        }
26    }
27    pub fn symbol_name(&self) -> &str {
28        self.header.name.as_ref()
29    }
30}
31
32impl From<EnumDef> for Definition {
33    fn from(this: EnumDef) -> Self {
34        Self::EnumDef(Box::new(this))
35    }
36}