1#[allow(missing_docs)]
7#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
8pub enum Status
9{
10 W3CRecommendation,
11 W3CProposedRecommendation,
12 W3CCandidateRecommendation,
13 W3CWorkingDraft,
14 WhatwgLivingStandard,
15 Other,
16 UnofficialOrNote,
17
18 #[doc(hidden)] __Nonexhaustive,
19
20 Unknown(String),
22}
23
24impl Default for Status
25{
26 #[inline(always)]
28 fn default() -> Self
29 {
30 Status::Other
31 }
32}
33
34impl<'de> Deserialize<'de> for Status
35{
36 fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
38 {
39 struct StatusVisitor;
40
41 impl<'de> Visitor<'de> for StatusVisitor
42 {
43 type Value = Status;
44
45 fn expecting(&self, formatter: &mut Formatter) -> fmt::Result
46 {
47 formatter.write_str("an era name starting with 'e' followed by a signed integer")
48 }
49
50 fn visit_str<E: de::Error>(self, v: &str) -> Result<Self::Value, E>
51 {
52 use self::Status::*;
53
54 let result = match v
55 {
56 "rec" => W3CRecommendation,
57 "pr" => W3CProposedRecommendation,
58 "cr" => W3CCandidateRecommendation,
59 "wd" => W3CWorkingDraft,
60 "ls" => WhatwgLivingStandard,
61 "other" => Other,
62 "unoff" => UnofficialOrNote,
63
64 _ => Unknown(v.to_owned()),
65 };
66 Ok(result)
67 }
68
69 fn visit_string<E: de::Error>(self, v: String) -> Result<Self::Value, E>
70 {
71 use self::Status::*;
72
73 let result = match &v[..]
74 {
75 "rec" => W3CRecommendation,
76 "pr" => W3CProposedRecommendation,
77 "cr" => W3CCandidateRecommendation,
78 "wd" => W3CWorkingDraft,
79 "ls" => WhatwgLivingStandard,
80 "other" => Other,
81 "unoff" => UnofficialOrNote,
82
83 _ => Unknown(v),
84 };
85 Ok(result)
86 }
87 }
88
89 deserializer.deserialize_str(StatusVisitor)
90 }
91}
92
93impl Status
94{
95 #[inline(always)]
98 pub fn description<'a>(&self, canIUse: &'a CanIUse) -> Option<&'a str>
99 {
100 canIUse.status_description(self)
101 }
102}