Revert changes made in lofty-attr

Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com>
This commit is contained in:
Serial 2021-06-30 00:53:16 -04:00
parent 37fc8ef905
commit 579902ceb5
3 changed files with 37 additions and 47 deletions

2
lofty-attr/Cargo.lock generated
View file

@ -4,7 +4,7 @@ version = 3
[[package]]
name = "lofty_attr"
version = "0.1.3"
version = "0.1.4"
dependencies = [
"quote",
"syn",

View file

@ -1,6 +1,6 @@
[package]
name = "lofty_attr"
version = "0.1.3"
version = "0.1.4"
authors = ["Serial <69764315+Serial-ATA@users.noreply.github.com>"]
description = "Macro for Lofty tag struct creation"
license = "MIT OR Apache-2.0"

View file

@ -23,50 +23,6 @@ pub fn impl_tag(args: TokenStream, input: TokenStream) -> TokenStream {
if let Some(inner) = inner.get_ident() {
let input_ident = input.ident;
let mut anytag_convert = quote! {
impl<'a> From<AnyTag<'a>> for #input_ident {
fn from(inp: AnyTag<'a>) -> Self {
let mut tag = #input_ident::default();
if let Some(v) = inp.title() {
tag.set_title(v)
}
if let Some(v) = inp.artists_as_string() {
tag.set_artist(&v)
}
if let Some(v) = inp.year {
tag.set_year(v)
}
if let Some(v) = inp.album().title {
tag.set_album_title(v)
}
if let Some(v) = inp.album().artists {
tag.set_album_artist(&v.join("/"))
}
if let Some(v) = inp.track_number() {
tag.set_track_number(v)
}
if let Some(v) = inp.total_tracks() {
tag.set_total_tracks(v)
}
if let Some(v) = inp.disc_number() {
tag.set_disc_number(v)
}
if let Some(v) = inp.total_discs() {
tag.set_total_discs(v)
}
tag
}
}
};
if let Some(attr) = input.attrs.first() {
if attr.path.is_ident("custom_convert") {
anytag_convert = quote! {};
}
}
let expanded = quote! {
#[doc(hidden)]
pub struct #input_ident {
@ -146,7 +102,41 @@ pub fn impl_tag(args: TokenStream, input: TokenStream) -> TokenStream {
}
}
#anytag_convert
impl<'a> From<AnyTag<'a>> for #input_ident {
fn from(inp: AnyTag<'a>) -> Self {
let mut tag = #input_ident::default();
if let Some(v) = inp.title() {
tag.set_title(v)
}
if let Some(v) = inp.artists_as_string() {
tag.set_artist(&v)
}
if let Some(v) = inp.year {
tag.set_year(v)
}
if let Some(v) = inp.album().title {
tag.set_album_title(v)
}
if let Some(v) = inp.album().artists {
tag.set_album_artist(&v.join("/"))
}
if let Some(v) = inp.track_number() {
tag.set_track_number(v)
}
if let Some(v) = inp.total_tracks() {
tag.set_total_tracks(v)
}
if let Some(v) = inp.disc_number() {
tag.set_disc_number(v)
}
if let Some(v) = inp.total_discs() {
tag.set_total_discs(v)
}
tag
}
}
// From dyn AudioTag to wrapper (any type)
impl From<Box<dyn AudioTag>> for #input_ident {