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
#[derive(Clone, Default, Debug)]
pub struct UInt16Value {
    value: Option<u16>,
}
impl UInt16Value {
    pub(crate) fn get_value(&self) -> &u16 {
        self.value.as_ref().unwrap_or(&0)
    }

    pub(crate) fn get_value_string(&self) -> String {
        self.get_value().to_string()
    }

    pub(crate) fn set_value(&mut self, value: u16) -> &mut UInt16Value {
        self.value = Some(value);
        self
    }

    pub(crate) fn set_value_string<S: Into<String>>(&mut self, value: S) -> &mut UInt16Value {
        self.set_value(value.into().parse::<u16>().unwrap())
    }

    pub(crate) fn _has_value(&self) -> bool {
        self.value.is_some()
    }
}