flash_lso/types/element.rs
1use super::Value;
2
3/// Represent a named element
4#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5#[derive(Clone, Debug, PartialEq)]
6pub struct Element {
7 /// The name of the element
8 pub name: String,
9
10 /// The value of the element
11 pub value: Value,
12}
13
14impl Element {
15 /// Create a new Element
16 #[inline]
17 pub fn new(name: impl Into<String>, value: Value) -> Self {
18 Self {
19 name: name.into(),
20 value,
21 }
22 }
23
24 /// Get the Value of this element
25 pub fn value(&self) -> &Value {
26 &self.value
27 }
28
29 /// Get the name of this element
30 pub fn name(&self) -> &str {
31 self.name.as_str()
32 }
33}