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
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Namespace {
Html,
Svg,
MathMl,
Xul,
Xbl,
Custom(String),
}
impl Namespace {
pub fn as_str(&self) -> &str {
match self {
Namespace::Html => "http://www.w3.org/1999/xhtml",
Namespace::Svg => "http://www.w3.org/2000/svg",
Namespace::MathMl => "http://www.w3.org/1998/mathml",
Namespace::Xul => "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
Namespace::Xbl => "http://www.mozilla.org/xbl",
Namespace::Custom(namespace) => namespace,
}
}
}
impl From<String> for Namespace {
fn from(namespace: String) -> Self {
match namespace.as_ref() {
"http://www.w3.org/1999/xhtml" => Namespace::Html,
"http://www.w3.org/2000/svg" => Namespace::Svg,
"http://www.w3.org/1998/mathml" => Namespace::MathMl,
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" => Namespace::Xul,
"http://www.mozilla.org/xbl" => Namespace::Xbl,
_ => Namespace::Custom(namespace),
}
}
}