teo_runtime/enum/member/
member.rs1
2use maplit::btreemap;
3use std::collections::BTreeMap;
4use serde::Serialize;
5use crate::value::Value;
6use crate::comment::Comment;
7use crate::traits::documentable::Documentable;
8use crate::traits::named::Named;
9
10#[derive(Debug, Serialize, Clone)]
11pub struct Member {
12 pub name: String,
13 pub comment: Option<Comment>,
14 pub value: Value,
15 pub data: BTreeMap<String, Value>,
16}
17
18impl Member {
19
20 pub fn new(name: String, value: Value, comment: Option<Comment>) -> Self {
21 Self { name, value, comment, data: btreemap! {} }
22 }
23
24 pub fn value(&self) -> &Value {
25 &self.value
26 }
27
28 pub fn data(&self) -> &BTreeMap<String, Value> {
29 &self.data
30 }
31}
32
33impl Named for Member {
34
35 fn name(&self) -> &str {
36 self.name.as_str()
37 }
38}
39
40impl Documentable for Member {
41
42 fn comment(&self) -> Option<&Comment> {
43 self.comment.as_ref()
44 }
45
46 fn kind(&self) -> &'static str {
47 "enum member"
48 }
49}