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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
use std::hash::{Hash, Hasher};
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Content {
Text(String),
ExtendedText(ExtendedText),
Link(String),
ExtendedLink(ExtendedLink),
Comment(Comment),
Lyrics(Lyrics),
Picture(Picture),
Unknown(Vec<u8>),
}
impl Content {
pub fn text(&self) -> Option<&str> {
match *self {
Content::Text(ref content) => Some(&*content),
_ => None,
}
}
pub fn extended_text(&self) -> Option<&super::ExtendedText> {
match *self {
Content::ExtendedText(ref content) => Some(content),
_ => None,
}
}
pub fn link(&self) -> Option<&str> {
match *self {
Content::Link(ref content) => Some(content),
_ => None,
}
}
pub fn extended_link(&self) -> Option<&super::ExtendedLink> {
match *self {
Content::ExtendedLink(ref content) => Some(content),
_ => None,
}
}
pub fn comment(&self) -> Option<&super::Comment> {
match *self {
Content::Comment(ref content) => Some(content),
_ => None,
}
}
pub fn lyrics(&self) -> Option<&super::Lyrics> {
match *self {
Content::Lyrics(ref content) => Some(content),
_ => None,
}
}
pub fn picture(&self) -> Option<&super::Picture> {
match *self {
Content::Picture(ref picture) => Some(picture),
_ => None,
}
}
pub fn unknown(&self) -> Option<&[u8]> {
match *self {
Content::Unknown(ref data) => Some(&data[..]),
_ => None,
}
}
}
#[derive(Clone, Debug, Eq)]
#[allow(missing_docs)]
pub struct ExtendedText {
pub description: String,
pub value: String,
}
impl PartialEq for ExtendedText {
fn eq(&self, other: &Self) -> bool {
self.description == other.description
}
}
impl Hash for ExtendedText {
fn hash<H: Hasher>(&self, state: &mut H) {
self.description.hash(state);
}
}
#[derive(Clone, Debug, Eq)]
#[allow(missing_docs)]
pub struct ExtendedLink {
pub description: String,
pub link: String,
}
impl PartialEq for ExtendedLink {
fn eq(&self, other: &Self) -> bool {
self.description == other.description
}
}
impl Hash for ExtendedLink {
fn hash<H: Hasher>(&self, state: &mut H) {
self.description.hash(state);
}
}
#[derive(Clone, Debug, Eq)]
#[allow(missing_docs)]
pub struct Comment {
pub lang: String,
pub description: String,
pub text: String,
}
impl PartialEq for Comment {
fn eq(&self, other: &Self) -> bool {
self.lang == other.lang && self.description == other.description
}
}
impl Hash for Comment {
fn hash<H: Hasher>(&self, state: &mut H) {
self.lang.hash(state);
self.description.hash(state);
}
}
#[derive(Clone, Debug, Eq)]
#[allow(missing_docs)]
pub struct Lyrics {
pub lang: String,
pub description: String,
pub text: String,
}
impl PartialEq for Lyrics {
fn eq(&self, other: &Self) -> bool {
self.lang == other.lang && self.description == other.description
}
}
impl Hash for Lyrics {
fn hash<H: Hasher>(&self, state: &mut H) {
self.lang.hash(state);
self.description.hash(state);
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[allow(missing_docs)]
pub enum PictureType {
Other,
Icon,
OtherIcon,
CoverFront,
CoverBack,
Leaflet,
Media,
LeadArtist,
Artist,
Conductor,
Band,
Composer,
Lyricist,
RecordingLocation,
DuringRecording,
DuringPerformance,
ScreenCapture,
BrightFish,
Illustration,
BandLogo,
PublisherLogo,
}
#[derive(Clone, Eq, Debug)]
pub struct Picture {
pub mime_type: String,
pub picture_type: PictureType,
pub description: String,
pub data: Vec<u8>,
}
impl PartialEq for Picture {
fn eq(&self, other: &Self) -> bool {
self.picture_type == other.picture_type
}
}
impl Hash for Picture {
fn hash<H: Hasher>(&self, state: &mut H) {
self.picture_type.hash(state);
}
}