umya_spreadsheet/structs/custom_properties/
custom_document_property_value.rs1use std::fmt;
2
3#[derive(Clone, Debug, PartialEq, PartialOrd)]
4pub enum CustomDocumentPropertyValue {
5 String(Box<str>),
6 Date(Box<str>),
7 Numeric(i32),
8 Bool(bool),
9 Null,
10}
11impl fmt::Display for CustomDocumentPropertyValue {
12 #[inline]
13 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14 match self {
15 Self::String(v) => write!(f, "{}", v),
16 Self::Date(v) => write!(f, "{}", v),
17 Self::Numeric(v) => write!(f, "{}", &v),
18 Self::Bool(v) => write!(f, "{}", if *v { "true" } else { "false" }),
19 _ => write!(f, ""),
20 }
21 }
22}
23impl Default for CustomDocumentPropertyValue {
24 #[inline]
25 fn default() -> Self {
26 Self::Null
27 }
28}
29impl CustomDocumentPropertyValue {
30 #[inline]
31 pub(crate) fn get_tag(&self) -> Option<&str> {
32 match self {
33 Self::String(_) => Some("vt:lpwstr"),
34 Self::Date(_) => Some("vt:filetime"),
35 Self::Numeric(_) => Some("vt:i4"),
36 Self::Bool(_) => Some("vt:bool"),
37 _ => None,
38 }
39 }
40
41 #[inline]
42 pub(crate) fn get_number(&self) -> Option<i32> {
43 match self {
44 Self::Numeric(number) => Some(*number),
45 _ => None,
46 }
47 }
48
49 #[inline]
50 pub(crate) fn get_bool(&self) -> Option<bool> {
51 match self {
52 Self::Bool(bool) => Some(*bool),
53 _ => None,
54 }
55 }
56}