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