diff --git a/assets/a.mp3 b/assets/a.mp3 index db418ef1..94f057cf 100644 Binary files a/assets/a.mp3 and b/assets/a.mp3 differ diff --git a/audiotags-dev-macro/src/lib.rs b/audiotags-dev-macro/src/lib.rs index f2db04ac..79aea52a 100644 --- a/audiotags-dev-macro/src/lib.rs +++ b/audiotags-dev-macro/src/lib.rs @@ -40,5 +40,20 @@ macro_rules! impl_tag { } impl AudioTag for $tag {} + + impl From<$tag> for $inner { + fn from(inp: $tag) -> Self { + inp.inner + } + } + + impl From<$inner> for $tag { + fn from(inp: $inner) -> Self { + Self { + inner: inp, + config: Config::default(), + } + } + } }; } diff --git a/src/components/flac_tag.rs b/src/components/flac_tag.rs index 645dfa40..197812a2 100644 --- a/src/components/flac_tag.rs +++ b/src/components/flac_tag.rs @@ -1,8 +1,9 @@ use crate::*; use metaflac; -use metaflac::Tag as InnerTag; -impl_tag!(FlacTag, InnerTag); +pub use metaflac::Tag as FlacInnerTag; + +impl_tag!(FlacTag, FlacInnerTag); impl<'a> From> for FlacTag { fn from(inp: AnyTag<'a>) -> Self { diff --git a/src/components/id3_tag.rs b/src/components/id3_tag.rs index a5024caf..c9a1c842 100644 --- a/src/components/id3_tag.rs +++ b/src/components/id3_tag.rs @@ -1,9 +1,9 @@ use crate::*; use id3; -use id3::Tag as InnerTag; +pub use id3::Tag as Id3v2InnerTag; -impl_tag!(Id3v2Tag, InnerTag); +impl_tag!(Id3v2Tag, Id3v2InnerTag); impl<'a> From<&'a Id3v2Tag> for AnyTag<'a> { fn from(inp: &'a Id3v2Tag) -> Self { diff --git a/src/components/mp4_tag.rs b/src/components/mp4_tag.rs index 7b2e592b..8cfae44f 100644 --- a/src/components/mp4_tag.rs +++ b/src/components/mp4_tag.rs @@ -1,9 +1,9 @@ use crate::*; use mp4ameta; -use mp4ameta::Tag as InnerTag; +pub use mp4ameta::Tag as Mp4InnerTag; -impl_tag!(Mp4Tag, InnerTag); +impl_tag!(Mp4Tag, Mp4InnerTag); impl<'a> From<&'a Mp4Tag> for AnyTag<'a> { fn from(inp: &'a Mp4Tag) -> Self { diff --git a/tests/inner.rs b/tests/inner.rs new file mode 100644 index 00000000..6f799ef9 --- /dev/null +++ b/tests/inner.rs @@ -0,0 +1,15 @@ +use audiotags::*; + +#[test] +fn test_inner() { + let mut innertag = metaflac::Tag::default(); + innertag + .vorbis_comments_mut() + .set_title(vec!["title from metaflac::Tag"]); + let tag: FlacTag = innertag.into(); + let mut id3tag = tag.into_tag(TagType::Id3v2); + id3tag.write_to_path("assets/a.mp3").unwrap(); + + let id3tag_reload = Tag::default().read_from_path("assets/a.mp3").unwrap(); + assert_eq!(id3tag_reload.title(), Some("title from metaflac::Tag")); +}