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
use std::fmt::{Display, Formatter};
use serde::Serialize;
use crate::arguments::Arguments;

#[derive(Debug, Clone, Serialize)]
pub struct InterfaceEnumVariant {
    pub value: String,
    pub args: Option<Arguments>,
}

impl InterfaceEnumVariant {

    pub fn value_only(value: String) -> Self {
        Self { value, args: None }
    }

    pub fn new(value: String, args: Arguments) -> Self {
        Self { value, args: Some(args) }
    }

    pub fn args(&self) -> Option<&Arguments> {
        self.args.as_ref()
    }

    pub fn value(&self) -> &str {
        self.value.as_str()
    }
}

impl Display for InterfaceEnumVariant {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.value())
    }
}