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
use id3::{frame, Frame};
use pipe_trait::Pipe;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
pub struct Comment<Language, Description, Content> {
pub language: Language,
pub description: Description,
pub content: Content,
}
impl<Language, Description, Content> Comment<Language, Description, Content> {
pub fn as_str_slices(&self) -> Comment<&'_ str, &'_ str, &'_ str>
where
Language: AsRef<str>,
Description: AsRef<str>,
Content: AsRef<str>,
{
Comment {
language: self.language.as_ref(),
description: self.description.as_ref(),
content: self.content.as_ref(),
}
}
pub fn to_owned_strings(&self) -> Comment<String, String, String>
where
Language: ToString,
Description: ToString,
Content: ToString,
{
Comment {
language: self.language.to_string(),
description: self.description.to_string(),
content: self.content.to_string(),
}
}
}
impl From<frame::Comment> for Comment<String, String, String> {
fn from(comment: frame::Comment) -> Self {
Comment {
language: comment.lang,
description: comment.description,
content: comment.text,
}
}
}
impl<'a> From<&'a frame::Comment> for Comment<&'a str, &'a str, &'a str> {
fn from(comment: &'a frame::Comment) -> Self {
Comment {
language: &comment.lang,
description: &comment.description,
content: &comment.text,
}
}
}
impl<Language, Description, Content> From<Comment<Language, Description, Content>>
for frame::Comment
where
Language: Into<String>,
Description: Into<String>,
Content: Into<String>,
{
fn from(comment: Comment<Language, Description, Content>) -> Self {
frame::Comment {
lang: comment.language.into(),
description: comment.description.into(),
text: comment.content.into(),
}
}
}
impl<Language, Description, Content> From<Comment<Language, Description, Content>> for Frame
where
Language: Into<String>,
Description: Into<String>,
Content: Into<String>,
{
fn from(comment: Comment<Language, Description, Content>) -> Self {
comment.pipe(frame::Comment::from).into()
}
}