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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use super::*;
use crate::nodes::{EmailLink, HyperLink, ImageLink, ResourceDescriptor, TagReference, TwoWayLink};
impl Debug for SmartLink {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::ExternalResource(v) => Debug::fmt(v, f),
Self::Reference(v) => Debug::fmt(v, f),
Self::Image(v) => Debug::fmt(v, f),
Self::Normal(v) => Debug::fmt(v, f),
Self::EMail(v) => Debug::fmt(v, f),
Self::TwoWay(v) => Debug::fmt(v, f),
}
}
}
impl Display for SmartLink {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
Self::Reference(v) => Display::fmt(v, f),
Self::Image(v) => Display::fmt(v, f),
Self::Normal(v) => Display::fmt(v, f),
Self::EMail(v) => Display::fmt(v, f),
Self::TwoWay(v) => Display::fmt(v, f),
Self::ExternalResource(v) => Display::fmt(v, f),
}
}
}
impl Display for ResourceDescriptor {
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
todo!()
}
}
impl Display for EmailLink {
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
todo!()
}
}
impl Display for TagReference {
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
todo!()
}
}
impl Display for ImageLink {
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
todo!()
}
}
impl Debug for ImageLink {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let w = &mut f.debug_struct("ImageLink");
w.field("src", &self.source);
if let Some(s) = &self.description {
w.field("alt", &s);
}
if let Some(s) = &self.size {
w.field("width", &s.0);
w.field("height", &s.1);
}
if let Some(s) = &self.layout {
w.field("layout", &s);
}
w.finish()
}
}
impl Debug for HyperLink {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let w = &mut f.debug_struct("HyperLink");
w.field("src", &self.src);
w.field("is_bare", &self.is_bare);
if let Some(s) = &self.text {
w.field("text", &s);
}
if let Some(s) = &self.download {
w.field("download", &s);
}
if let Some(s) = &self.target {
w.field("target", &s);
}
w.finish()
}
}
impl Display for HyperLink {
// SmartLink::Path { path: from, to, alt, bind } => {
// let from_to = match to {
// None => format!("[{}]", from),
// Some(to) => format!("[{} > {}]", from, to),
// };
// match (bind, alt) {
// (None, None) => write!(f, "{}", from_to),
// (Some(bind), None) => write!(f, "{}[:{}]", from_to, bind),
// (None, Some(alt)) => write!(f, "{}[{}]", from_to, alt),
// (Some(bind), Some(alt)) => write!(f, "{}[{}:{}]", from_to, bind, alt),
// }
// }
// SmartLink::PathWithText { text: img, path: to, alt, bind } => {
// let img_to = match to {
// None => format!("[{}]", img),
// Some(s) => format!("[{} > {}]", img, s),
// };
// match (bind, alt) {
// (None, None) => write!(f, "{}", img_to),
// (Some(bind), None) => write!(f, "{}[:{}]", img_to, bind),
// (None, Some(alt)) => write!(f, "{}[{}]", img_to, alt),
// (Some(bind), Some(alt)) => write!(f, "{}[{}:{}]", img_to, bind, alt),
// }
// }
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
todo!()
}
}
impl Display for TwoWayLink {
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
todo!()
}
}