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
37
38
39
40
41
42
43
44
45
#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct StringValue {
value: Option<String>,
value_default: String,
}
impl StringValue {
pub(crate) fn get_value(&self) -> &str {
match &self.value {
Some(v) => v,
None => &self.value_default,
}
}
pub(crate) fn get_value_string(&self) -> &str {
self.get_value()
}
pub(crate) fn set_value<S: Into<String>>(&mut self, value: S) -> &mut StringValue {
self.value = Some(value.into());
self
}
pub(crate) fn set_value_string<S: Into<String>>(&mut self, value: S) -> &mut StringValue {
self.set_value(value.into())
}
pub(crate) fn remove_value(&mut self) -> &mut Self {
self.value = None;
self
}
pub(crate) fn has_value(&self) -> bool {
match &self.value {
Some(_) => true,
None => false,
}
}
pub(crate) fn get_hash_string(&self) -> &str {
if self.has_value() {
return self.get_value_string();
}
"empty!!"
}
}