teo_parser/value/
interface_enum_variant.rs1use std::collections::BTreeMap;
2use std::fmt::{Display, Formatter, Write};
3use serde::Serialize;
4use crate::value::Value;
5
6#[derive(Debug, Clone, PartialEq, Serialize)]
7pub struct InterfaceEnumVariant {
8 pub value: String,
9 pub args: Option<BTreeMap<String, Value>>,
10}
11
12impl InterfaceEnumVariant {
13
14 pub fn into_string(self) -> String {
15 self.value
16 }
17
18 pub fn to_string(&self) -> String {
19 self.value.clone()
20 }
21
22 pub fn normal_not(&self) -> bool {
23 false
24 }
25}
26
27impl Display for InterfaceEnumVariant {
28 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29 f.write_str(".")?;
30 f.write_str(self.value.as_str())?;
31 if let Some(args) = &self.args {
32 f.write_str("(...args)")?;
33 }
34 Ok(())
35 }
36}