umya_spreadsheet/structs/
byte_value.rs1#[derive(Clone, Default, Debug)]
2pub struct ByteValue {
3 value: Option<u8>,
4}
5impl ByteValue {
6 #[inline]
7 pub(crate) fn get_value(&self) -> &u8 {
8 match &self.value {
9 Some(v) => v,
10 None => &0,
11 }
12 }
13
14 #[inline]
15 pub(crate) fn get_value_string(&self) -> String {
16 self.get_value().to_string()
17 }
18
19 #[inline]
20 pub(crate) fn set_value(&mut self, value: u8) -> &mut ByteValue {
21 self.value = Some(value);
22 self
23 }
24
25 #[inline]
26 pub(crate) fn set_value_string<S: Into<String>>(&mut self, value: S) -> &mut ByteValue {
27 self.set_value(value.into().parse::<u8>().unwrap())
28 }
29
30 #[inline]
31 pub(crate) fn has_value(&self) -> bool {
32 self.value.is_some()
33 }
34}