docx_rs/types/
shd_type.rs

1use serde::{Deserialize, Serialize};
2
3use std::fmt;
4use std::str::FromStr;
5#[cfg(feature = "wasm")]
6use wasm_bindgen::prelude::*;
7
8use super::errors;
9
10/*
11<xsd:enumeration value="nil"/>
12<xsd:enumeration value="clear"/>
13<xsd:enumeration value="solid"/>
14<xsd:enumeration value="horzStripe"/>
15<xsd:enumeration value="vertStripe"/>
16<xsd:enumeration value="reverseDiagStripe"/>
17<xsd:enumeration value="diagStripe"/>
18<xsd:enumeration value="horzCross"/>
19<xsd:enumeration value="diagCross"/>
20<xsd:enumeration value="thinHorzStripe"/>
21<xsd:enumeration value="thinVertStripe"/>
22<xsd:enumeration value="thinReverseDiagStripe"/>
23<xsd:enumeration value="thinDiagStripe"/>
24<xsd:enumeration value="thinHorzCross"/>
25<xsd:enumeration value="thinDiagCross"/>
26<xsd:enumeration value="pct5"/>
27<xsd:enumeration value="pct10"/>
28<xsd:enumeration value="pct12"/>
29<xsd:enumeration value="pct15"/>
30<xsd:enumeration value="pct20"/>
31<xsd:enumeration value="pct25"/>
32<xsd:enumeration value="pct30"/>
33<xsd:enumeration value="pct35"/>
34<xsd:enumeration value="pct37"/>
35<xsd:enumeration value="pct40"/>
36<xsd:enumeration value="pct45"/>
37<xsd:enumeration value="pct50"/>
38<xsd:enumeration value="pct55"/>
39<xsd:enumeration value="pct60"/>
40<xsd:enumeration value="pct62"/>
41<xsd:enumeration value="pct65"/>
42<xsd:enumeration value="pct70"/>
43<xsd:enumeration value="pct75"/>
44<xsd:enumeration value="pct80"/>
45<xsd:enumeration value="pct85"/>
46<xsd:enumeration value="pct87"/>
47<xsd:enumeration value="pct90"/>
48<xsd:enumeration value="pct95"/>
49*/
50#[cfg_attr(feature = "wasm", wasm_bindgen)]
51#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
52#[serde(rename_all = "camelCase")]
53pub enum ShdType {
54    Nil,
55    Clear,
56    Solid,
57    HorzStripe,
58    VertStripe,
59    ReverseDiagStripe,
60    DiagStripe,
61    HorzCross,
62    DiagCross,
63    ThinHorzStripe,
64    ThinVertStripe,
65    ThinReverseDiagStripe,
66    ThinDiagStripe,
67    ThinHorzCross,
68    ThinDiagCross,
69    Pct5,
70    Pct10,
71    Pct12,
72    Pct15,
73    Pct20,
74    Pct25,
75    Pct30,
76    Pct35,
77    Pct37,
78    Pct40,
79    Pct45,
80    Pct50,
81    Pct55,
82    Pct60,
83    Pct62,
84    Pct65,
85    Pct70,
86    Pct75,
87    Pct80,
88    Pct85,
89    Pct87,
90    Pct90,
91    Pct95,
92}
93
94impl fmt::Display for ShdType {
95    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
96        match *self {
97            ShdType::Nil => write!(f, "nil"),
98            ShdType::Clear => write!(f, "clear"),
99            ShdType::Solid => write!(f, "solid"),
100            ShdType::HorzStripe => write!(f, "horzStripe"),
101            ShdType::VertStripe => write!(f, "vertStripe"),
102            ShdType::ReverseDiagStripe => write!(f, "reverseDiagStripe"),
103            ShdType::DiagStripe => write!(f, "diagStripe"),
104            ShdType::HorzCross => write!(f, "horzCross"),
105            ShdType::DiagCross => write!(f, "diagCross"),
106            ShdType::ThinHorzStripe => write!(f, "thinHorzStripe"),
107            ShdType::ThinVertStripe => write!(f, "thinVertStripe"),
108            ShdType::ThinReverseDiagStripe => write!(f, "thinReverseDiagStripe"),
109            ShdType::ThinDiagStripe => write!(f, "thinDiagStripe"),
110            ShdType::ThinHorzCross => write!(f, "thinHorzCross"),
111            ShdType::ThinDiagCross => write!(f, "thinDiagCross"),
112            ShdType::Pct5 => write!(f, "pct5"),
113            ShdType::Pct10 => write!(f, "pct10"),
114            ShdType::Pct12 => write!(f, "pct12"),
115            ShdType::Pct15 => write!(f, "pct15"),
116            ShdType::Pct20 => write!(f, "pct20"),
117            ShdType::Pct25 => write!(f, "pct25"),
118            ShdType::Pct30 => write!(f, "pct30"),
119            ShdType::Pct35 => write!(f, "pct35"),
120            ShdType::Pct37 => write!(f, "pct37"),
121            ShdType::Pct40 => write!(f, "pct40"),
122            ShdType::Pct45 => write!(f, "pct45"),
123            ShdType::Pct50 => write!(f, "pct50"),
124            ShdType::Pct55 => write!(f, "pct55"),
125            ShdType::Pct60 => write!(f, "pct60"),
126            ShdType::Pct62 => write!(f, "pct62"),
127            ShdType::Pct65 => write!(f, "pct65"),
128            ShdType::Pct70 => write!(f, "pct70"),
129            ShdType::Pct75 => write!(f, "pct75"),
130            ShdType::Pct80 => write!(f, "pct80"),
131            ShdType::Pct85 => write!(f, "pct85"),
132            ShdType::Pct87 => write!(f, "pct87"),
133            ShdType::Pct90 => write!(f, "pct90"),
134            ShdType::Pct95 => write!(f, "pct95"),
135        }
136    }
137}
138
139impl FromStr for ShdType {
140    type Err = errors::TypeError;
141    fn from_str(s: &str) -> Result<Self, Self::Err> {
142        match s {
143            "nil" => Ok(ShdType::Nil),
144            "clear" => Ok(ShdType::Clear),
145            "solid" => Ok(ShdType::Solid),
146            "horzStripe" => Ok(ShdType::HorzStripe),
147            "vertStripe" => Ok(ShdType::VertStripe),
148            "reverseDiagStripe" => Ok(ShdType::ReverseDiagStripe),
149            "diagStripe" => Ok(ShdType::DiagStripe),
150            "horzCross" => Ok(ShdType::HorzCross),
151            "diagCross" => Ok(ShdType::DiagCross),
152            "thinHorzStripe" => Ok(ShdType::ThinHorzStripe),
153            "thinVertStripe" => Ok(ShdType::ThinVertStripe),
154            "thinReverseDiagStripe" => Ok(ShdType::ThinReverseDiagStripe),
155            "thinDiagStripe" => Ok(ShdType::ThinDiagStripe),
156            "thinHorzCross" => Ok(ShdType::ThinHorzCross),
157            "thinDiagCross" => Ok(ShdType::ThinDiagCross),
158            "pct5" => Ok(ShdType::Pct5),
159            "pct10" => Ok(ShdType::Pct10),
160            "pct12" => Ok(ShdType::Pct12),
161            "pct15" => Ok(ShdType::Pct15),
162            "pct20" => Ok(ShdType::Pct20),
163            "pct25" => Ok(ShdType::Pct25),
164            "pct30" => Ok(ShdType::Pct30),
165            "pct35" => Ok(ShdType::Pct35),
166            "pct37" => Ok(ShdType::Pct37),
167            "pct40" => Ok(ShdType::Pct40),
168            "pct45" => Ok(ShdType::Pct45),
169            "pct50" => Ok(ShdType::Pct50),
170            "pct55" => Ok(ShdType::Pct55),
171            "pct60" => Ok(ShdType::Pct60),
172            "pct62" => Ok(ShdType::Pct62),
173            "pct65" => Ok(ShdType::Pct65),
174            "pct70" => Ok(ShdType::Pct70),
175            "pct75" => Ok(ShdType::Pct75),
176            "pct80" => Ok(ShdType::Pct80),
177            "pct85" => Ok(ShdType::Pct85),
178            "pct87" => Ok(ShdType::Pct87),
179            "pct90" => Ok(ShdType::Pct90),
180            "pct95" => Ok(ShdType::Pct95),
181            _ => Err(errors::TypeError::Unknown),
182        }
183    }
184}