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
pub mod doc_type;
pub mod element;
pub mod document;
pub mod macros;
pub use doc_type::DomDocType;
pub use element::{DomEmptyElem, DomElem};
pub use document::DomDocument;
pub use macros::*;
pub trait Render {
fn render(&self) -> String;
}
#[derive(Debug, Clone)]
pub enum DomNode {
Document(DomDocument),
DocumentType(DomDocType),
EmptyElement(DomEmptyElem),
Element(DomElem),
Text(String),
}
pub use DomNode::*;
impl Render for DomNode {
fn render(&self) -> String {
match self {
Document(n) => n.render(),
DocumentType(n) => n.render(),
EmptyElement(n) => n.render(),
Element(n) => n.render(),
Text(n) => n.to_string(),
}
}
}