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
use std::collections::BTreeMap;
use std::fmt::{Display, Formatter, Write};
use serde::Serialize;
use crate::value::Value;

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

impl InterfaceEnumVariant {

    pub fn into_string(self) -> String {
        self.value
    }

    pub fn to_string(&self) -> String {
        self.value.clone()
    }

    pub fn normal_not(&self) -> bool {
        false
    }
}

impl Display for InterfaceEnumVariant {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str(".")?;
        f.write_str(self.value.as_str())?;
        if let Some(args) = &self.args {
            f.write_str("(...args)")?;
        }
        Ok(())
    }
}