mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
Tag: Properly capitalize TagType
variants
This commit is contained in:
parent
2c90093aa2
commit
4420f92a9f
36 changed files with 148 additions and 142 deletions
|
@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Bitrates in properties will be rounded up, similar to FFmpeg and TagLib
|
||||
- **ID3v2**: Insert multi-value frames separately when converting to `Tag`
|
||||
- E.g. An artist of "foo/bar/baz" will become 3 different `TagItem`s with `ItemKey::TrackArtist`
|
||||
- Properly capitalized the variants of `TagType`
|
||||
- `Ape` -> `APE`
|
||||
- `Id3v1` -> `ID3v1`
|
||||
- `Id3v2` -> `ID3v2`
|
||||
- `Mp4Ilst` -> `MP4ilst`
|
||||
- `RiffInfo` -> `RIFFInfo`
|
||||
- `AiffText` -> `AIFFText`
|
||||
|
||||
## [0.6.3] - 2022-05-18
|
||||
|
||||
|
|
|
@ -101,11 +101,11 @@ impl AudioFile for ApeFile {
|
|||
fn contains_tag_type(&self, tag_type: TagType) -> bool {
|
||||
match tag_type {
|
||||
#[cfg(feature = "ape")]
|
||||
TagType::Ape => self.ape_tag.is_some(),
|
||||
TagType::APE => self.ape_tag.is_some(),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::Id3v1 => self.id3v1_tag.is_some(),
|
||||
TagType::ID3v1 => self.id3v1_tag.is_some(),
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => self.id3v2_tag.is_some(),
|
||||
TagType::ID3v2 => self.id3v2_tag.is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ impl TryFrom<TagItem> for ApeItem {
|
|||
Self::new(
|
||||
value
|
||||
.item_key
|
||||
.map_key(TagType::Ape, false)
|
||||
.map_key(TagType::APE, false)
|
||||
.ok_or_else(|| {
|
||||
FileDecodingError::new(
|
||||
FileType::APE,
|
||||
|
|
|
@ -165,11 +165,11 @@ impl TagExt for ApeTag {
|
|||
}
|
||||
|
||||
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Ape.remove_from_path(path)
|
||||
TagType::APE.remove_from_path(path)
|
||||
}
|
||||
|
||||
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Ape.remove_from(file)
|
||||
TagType::APE.remove_from(file)
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
|
@ -198,10 +198,10 @@ impl From<ApeTag> for Tag {
|
|||
Some(())
|
||||
}
|
||||
|
||||
let mut tag = Tag::new(TagType::Ape);
|
||||
let mut tag = Tag::new(TagType::APE);
|
||||
|
||||
for item in input.items {
|
||||
let item_key = ItemKey::from_key(TagType::Ape, item.key());
|
||||
let item_key = ItemKey::from_key(TagType::APE, item.key());
|
||||
|
||||
// The text pairs need some special treatment
|
||||
match (item_key, item.value()) {
|
||||
|
@ -275,7 +275,7 @@ where
|
|||
|
||||
pub(crate) fn tagitems_into_ape(items: &[TagItem]) -> impl Iterator<Item = ApeItemRef<'_>> {
|
||||
items.iter().filter_map(|i| {
|
||||
i.key().map_key(TagType::Ape, true).map(|key| ApeItemRef {
|
||||
i.key().map_key(TagType::APE, true).map(|key| ApeItemRef {
|
||||
read_only: false,
|
||||
key,
|
||||
value: (&i.item_value).into(),
|
||||
|
@ -395,7 +395,7 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::Ape);
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::APE);
|
||||
|
||||
let ape_tag: ApeTag = tag.into();
|
||||
|
||||
|
|
|
@ -14,16 +14,16 @@ use std::fs::File;
|
|||
pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
|
||||
match tag.tag_type() {
|
||||
#[cfg(feature = "ape")]
|
||||
TagType::Ape => ape::tag::ApeTagRef {
|
||||
TagType::APE => ape::tag::ApeTagRef {
|
||||
read_only: false,
|
||||
items: ape::tag::tagitems_into_ape(tag.items()),
|
||||
}
|
||||
.write_to(data),
|
||||
// This tag can *only* be removed in this format
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => v2::tag::Id3v2TagRef::empty().write_to(data),
|
||||
TagType::ID3v2 => v2::tag::Id3v2TagRef::empty().write_to(data),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::Id3v1 => Into::<v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(data),
|
||||
TagType::ID3v1 => Into::<v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(data),
|
||||
_ => Err(LoftyError::new(ErrorKind::UnsupportedTag)),
|
||||
}
|
||||
}
|
||||
|
|
28
src/file.rs
28
src/file.rs
|
@ -226,21 +226,21 @@ impl FileType {
|
|||
pub fn primary_tag_type(&self) -> TagType {
|
||||
match self {
|
||||
#[cfg(all(not(feature = "id3v2"), feature = "aiff_text_chunks"))]
|
||||
FileType::AIFF => TagType::AiffText,
|
||||
FileType::AIFF => TagType::AIFFText,
|
||||
#[cfg(all(not(feature = "id3v2"), feature = "riff_info_list"))]
|
||||
FileType::WAV => TagType::RiffInfo,
|
||||
FileType::WAV => TagType::RIFFInfo,
|
||||
#[cfg(all(not(feature = "id3v2"), feature = "id3v1"))]
|
||||
FileType::MP3 => TagType::Id3v1,
|
||||
FileType::MP3 => TagType::ID3v1,
|
||||
#[cfg(all(not(feature = "id3v2"), not(feature = "id3v1"), feature = "ape"))]
|
||||
FileType::MP3 => TagType::Ape,
|
||||
FileType::AIFF | FileType::MP3 | FileType::WAV => TagType::Id3v2,
|
||||
FileType::MP3 => TagType::APE,
|
||||
FileType::AIFF | FileType::MP3 | FileType::WAV => TagType::ID3v2,
|
||||
#[cfg(all(not(feature = "ape"), feature = "id3v1"))]
|
||||
FileType::MP3 | FileType::WavPack => TagType::Id3v1,
|
||||
FileType::APE | FileType::WavPack => TagType::Ape,
|
||||
FileType::MP3 | FileType::WavPack => TagType::ID3v1,
|
||||
FileType::APE | FileType::WavPack => TagType::APE,
|
||||
FileType::FLAC | FileType::Opus | FileType::Vorbis | FileType::Speex => {
|
||||
TagType::VorbisComments
|
||||
},
|
||||
FileType::MP4 => TagType::Mp4Ilst,
|
||||
FileType::MP4 => TagType::MP4ilst,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,24 +249,24 @@ impl FileType {
|
|||
match self {
|
||||
#[cfg(feature = "id3v2")]
|
||||
FileType::AIFF | FileType::APE | FileType::MP3 | FileType::WAV
|
||||
if tag_type == TagType::Id3v2 =>
|
||||
if tag_type == TagType::ID3v2 =>
|
||||
{
|
||||
true
|
||||
},
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
FileType::AIFF if tag_type == TagType::AiffText => true,
|
||||
FileType::AIFF if tag_type == TagType::AIFFText => true,
|
||||
#[cfg(feature = "id3v1")]
|
||||
FileType::APE | FileType::MP3 | FileType::WavPack if tag_type == TagType::Id3v1 => true,
|
||||
FileType::APE | FileType::MP3 | FileType::WavPack if tag_type == TagType::ID3v1 => true,
|
||||
#[cfg(feature = "ape")]
|
||||
FileType::APE | FileType::MP3 | FileType::WavPack if tag_type == TagType::Ape => true,
|
||||
FileType::APE | FileType::MP3 | FileType::WavPack if tag_type == TagType::APE => true,
|
||||
#[cfg(feature = "vorbis_comments")]
|
||||
FileType::Opus | FileType::FLAC | FileType::Vorbis | FileType::Speex => {
|
||||
tag_type == TagType::VorbisComments
|
||||
},
|
||||
#[cfg(feature = "mp4_ilst")]
|
||||
FileType::MP4 => tag_type == TagType::Mp4Ilst,
|
||||
FileType::MP4 => tag_type == TagType::MP4ilst,
|
||||
#[cfg(feature = "riff_info_list")]
|
||||
FileType::WAV => tag_type == TagType::RiffInfo,
|
||||
FileType::WAV => tag_type == TagType::RIFFInfo,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,11 +142,11 @@ impl TagExt for Id3v1Tag {
|
|||
}
|
||||
|
||||
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Id3v1.remove_from_path(path)
|
||||
TagType::ID3v1.remove_from_path(path)
|
||||
}
|
||||
|
||||
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Id3v1.remove_from(file)
|
||||
TagType::ID3v1.remove_from(file)
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
|
@ -156,7 +156,7 @@ impl TagExt for Id3v1Tag {
|
|||
|
||||
impl From<Id3v1Tag> for Tag {
|
||||
fn from(input: Id3v1Tag) -> Self {
|
||||
let mut tag = Self::new(TagType::Id3v1);
|
||||
let mut tag = Self::new(TagType::ID3v1);
|
||||
|
||||
input.title.map(|t| tag.insert_text(ItemKey::TrackTitle, t));
|
||||
input
|
||||
|
@ -328,7 +328,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn tag_to_id3v1() {
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::Id3v1);
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::ID3v1);
|
||||
|
||||
let id3v1_tag: Id3v1Tag = tag.into();
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ impl TryFrom<ItemKey> for FrameID {
|
|||
{
|
||||
Ok(Self::Valid(unknown))
|
||||
},
|
||||
k => k.map_key(TagType::Id3v2, false).map_or(
|
||||
k => k.map_key(TagType::ID3v2, false).map_or(
|
||||
Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameID).into()),
|
||||
|id| Ok(Self::Valid(id.to_string())),
|
||||
),
|
||||
|
|
|
@ -328,7 +328,7 @@ impl<'a> TryFrom<&'a TagItem> for FrameRef<'a> {
|
|||
Ok(unknown.as_str())
|
||||
},
|
||||
k => k
|
||||
.map_key(TagType::Id3v2, false)
|
||||
.map_key(TagType::ID3v2, false)
|
||||
.ok_or_else(|| Id3v2Error::new(Id3v2ErrorKind::BadFrameID)),
|
||||
}?;
|
||||
|
||||
|
|
|
@ -313,11 +313,11 @@ impl TagExt for Id3v2Tag {
|
|||
}
|
||||
|
||||
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Id3v2.remove_from_path(path)
|
||||
TagType::ID3v2.remove_from_path(path)
|
||||
}
|
||||
|
||||
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Id3v2.remove_from(file)
|
||||
TagType::ID3v2.remove_from(file)
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
|
@ -346,7 +346,7 @@ impl From<Id3v2Tag> for Tag {
|
|||
Some(())
|
||||
}
|
||||
|
||||
let mut tag = Self::new(TagType::Id3v2);
|
||||
let mut tag = Self::new(TagType::ID3v2);
|
||||
|
||||
'outer: for frame in input.frames {
|
||||
let id = frame.id_str();
|
||||
|
@ -368,7 +368,7 @@ impl From<Id3v2Tag> for Tag {
|
|||
_ => {},
|
||||
}
|
||||
|
||||
let item_key = ItemKey::from_key(TagType::Id3v2, id);
|
||||
let item_key = ItemKey::from_key(TagType::ID3v2, id);
|
||||
|
||||
let item_value = match frame.value {
|
||||
FrameValue::Comment(LanguageFrame { content, .. })
|
||||
|
@ -658,7 +658,7 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::Id3v2);
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::ID3v2);
|
||||
|
||||
let id3v2_tag: Id3v2Tag = tag.into();
|
||||
|
||||
|
@ -820,7 +820,7 @@ mod tests {
|
|||
picture_data,
|
||||
);
|
||||
|
||||
let mut tag = Tag::new(TagType::Id3v2);
|
||||
let mut tag = Tag::new(TagType::ID3v2);
|
||||
tag.push_picture(picture.clone());
|
||||
|
||||
let mut writer = Vec::new();
|
||||
|
|
|
@ -76,9 +76,9 @@ impl AudioFile for AiffFile {
|
|||
fn contains_tag_type(&self, tag_type: TagType) -> bool {
|
||||
match tag_type {
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => self.id3v2_tag.is_some(),
|
||||
TagType::ID3v2 => self.id3v2_tag.is_some(),
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
TagType::AiffText => self.text_chunks.is_some(),
|
||||
TagType::AIFFText => self.text_chunks.is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,11 +167,11 @@ impl TagExt for AiffTextChunks {
|
|||
}
|
||||
|
||||
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
TagType::AiffText.remove_from_path(path)
|
||||
TagType::AIFFText.remove_from_path(path)
|
||||
}
|
||||
|
||||
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
TagType::AiffText.remove_from(file)
|
||||
TagType::AIFFText.remove_from(file)
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
|
@ -181,7 +181,7 @@ impl TagExt for AiffTextChunks {
|
|||
|
||||
impl From<AiffTextChunks> for Tag {
|
||||
fn from(input: AiffTextChunks) -> Self {
|
||||
let mut tag = Tag::new(TagType::AiffText);
|
||||
let mut tag = Tag::new(TagType::AIFFText);
|
||||
|
||||
let push_item = |field: Option<String>, item_key: ItemKey, tag: &mut Tag| {
|
||||
if let Some(text) = field {
|
||||
|
@ -492,7 +492,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn tag_to_aiff_text() {
|
||||
let mut tag = Tag::new(TagType::AiffText);
|
||||
let mut tag = Tag::new(TagType::AIFFText);
|
||||
tag.insert_text(ItemKey::TrackTitle, String::from("Foo title"));
|
||||
tag.insert_text(ItemKey::TrackArtist, String::from("Bar artist"));
|
||||
tag.insert_text(ItemKey::CopyrightMessage, String::from("Baz copyright"));
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::fs::File;
|
|||
pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
|
||||
match tag.tag_type() {
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
TagType::AiffText => {
|
||||
TagType::AIFFText => {
|
||||
use crate::tag::item::ItemKey;
|
||||
|
||||
super::tag::AiffTextChunksRef {
|
||||
|
@ -23,7 +23,7 @@ pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
|
|||
}
|
||||
.write_to(data),
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => v2::tag::Id3v2TagRef {
|
||||
TagType::ID3v2 => v2::tag::Id3v2TagRef {
|
||||
flags: v2::Id3v2TagFlags::default(),
|
||||
frames: v2::tag::tag_frames(tag),
|
||||
}
|
||||
|
|
|
@ -80,9 +80,9 @@ impl AudioFile for WavFile {
|
|||
fn contains_tag_type(&self, tag_type: TagType) -> bool {
|
||||
match tag_type {
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => self.id3v2_tag.is_some(),
|
||||
TagType::ID3v2 => self.id3v2_tag.is_some(),
|
||||
#[cfg(feature = "riff_info_list")]
|
||||
TagType::RiffInfo => self.riff_info.is_some(),
|
||||
TagType::RIFFInfo => self.riff_info.is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,11 +121,11 @@ impl TagExt for RiffInfoList {
|
|||
}
|
||||
|
||||
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
TagType::RiffInfo.remove_from_path(path)
|
||||
TagType::RIFFInfo.remove_from_path(path)
|
||||
}
|
||||
|
||||
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
TagType::RiffInfo.remove_from(file)
|
||||
TagType::RIFFInfo.remove_from(file)
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
|
@ -135,10 +135,10 @@ impl TagExt for RiffInfoList {
|
|||
|
||||
impl From<RiffInfoList> for Tag {
|
||||
fn from(input: RiffInfoList) -> Self {
|
||||
let mut tag = Tag::new(TagType::RiffInfo);
|
||||
let mut tag = Tag::new(TagType::RIFFInfo);
|
||||
|
||||
for (k, v) in input.items {
|
||||
let item_key = ItemKey::from_key(TagType::RiffInfo, &k);
|
||||
let item_key = ItemKey::from_key(TagType::RIFFInfo, &k);
|
||||
|
||||
tag.items.push(TagItem::new(
|
||||
item_key,
|
||||
|
@ -163,7 +163,7 @@ impl From<Tag> for RiffInfoList {
|
|||
}
|
||||
},
|
||||
k => {
|
||||
if let Some(key) = k.map_key(TagType::RiffInfo, false) {
|
||||
if let Some(key) = k.map_key(TagType::RIFFInfo, false) {
|
||||
riff_info.items.push((key.to_string(), val))
|
||||
}
|
||||
},
|
||||
|
@ -206,7 +206,7 @@ where
|
|||
|
||||
pub(crate) fn tagitems_into_riff(items: &[TagItem]) -> impl Iterator<Item = (&str, &str)> {
|
||||
items.iter().filter_map(|i| {
|
||||
let item_key = i.key().map_key(TagType::RiffInfo, true);
|
||||
let item_key = i.key().map_key(TagType::RIFFInfo, true);
|
||||
|
||||
match (item_key, i.value()) {
|
||||
(Some(key), ItemValue::Text(val) | ItemValue::Locator(val))
|
||||
|
@ -305,7 +305,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn tag_to_riff_info() {
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::RiffInfo);
|
||||
let tag = crate::tag::utils::test_utils::create_tag(TagType::RIFFInfo);
|
||||
|
||||
let riff_info: RiffInfoList = tag.into();
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ use std::fs::File;
|
|||
pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
|
||||
match tag.tag_type() {
|
||||
#[cfg(feature = "riff_info_list")]
|
||||
TagType::RiffInfo => {
|
||||
TagType::RIFFInfo => {
|
||||
super::tag::RiffInfoListRef::new(super::tag::tagitems_into_riff(tag.items()))
|
||||
.write_to(data)
|
||||
},
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => v2::tag::Id3v2TagRef {
|
||||
TagType::ID3v2 => v2::tag::Id3v2TagRef {
|
||||
flags: v2::Id3v2TagFlags::default(),
|
||||
frames: v2::tag::tag_frames(tag),
|
||||
}
|
||||
|
|
|
@ -103,8 +103,8 @@
|
|||
//! assert_eq!(mp3_file.properties().channels(), 2);
|
||||
//!
|
||||
//! // Here we have a file with multiple tags
|
||||
//! assert!(mp3_file.contains_tag_type(TagType::Id3v2));
|
||||
//! assert!(mp3_file.contains_tag_type(TagType::Ape));
|
||||
//! assert!(mp3_file.contains_tag_type(TagType::ID3v2));
|
||||
//! assert!(mp3_file.contains_tag_type(TagType::APE));
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! ```
|
||||
|
|
|
@ -86,11 +86,11 @@ impl AudioFile for Mp3File {
|
|||
fn contains_tag_type(&self, tag_type: TagType) -> bool {
|
||||
match tag_type {
|
||||
#[cfg(feature = "ape")]
|
||||
TagType::Ape => self.ape_tag.is_some(),
|
||||
TagType::APE => self.ape_tag.is_some(),
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => self.id3v2_tag.is_some(),
|
||||
TagType::ID3v2 => self.id3v2_tag.is_some(),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::Id3v1 => self.id3v1_tag.is_some(),
|
||||
TagType::ID3v1 => self.id3v1_tag.is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ use std::fs::File;
|
|||
pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
|
||||
match tag.tag_type() {
|
||||
#[cfg(feature = "ape")]
|
||||
TagType::Ape => ape::tag::ApeTagRef {
|
||||
TagType::APE => ape::tag::ApeTagRef {
|
||||
read_only: false,
|
||||
items: ape::tag::tagitems_into_ape(tag.items()),
|
||||
}
|
||||
.write_to(data),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::Id3v1 => Into::<v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(data),
|
||||
TagType::ID3v1 => Into::<v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(data),
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => v2::tag::Id3v2TagRef {
|
||||
TagType::ID3v2 => v2::tag::Id3v2TagRef {
|
||||
flags: v2::Id3v2TagFlags::default(),
|
||||
frames: v2::tag::tag_frames(tag),
|
||||
}
|
||||
|
|
|
@ -249,11 +249,11 @@ impl TagExt for Ilst {
|
|||
}
|
||||
|
||||
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Mp4Ilst.remove_from_path(path)
|
||||
TagType::MP4ilst.remove_from_path(path)
|
||||
}
|
||||
|
||||
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
|
||||
TagType::Mp4Ilst.remove_from(file)
|
||||
TagType::MP4ilst.remove_from(file)
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
|
@ -263,7 +263,7 @@ impl TagExt for Ilst {
|
|||
|
||||
impl From<Ilst> for Tag {
|
||||
fn from(input: Ilst) -> Self {
|
||||
let mut tag = Self::new(TagType::Mp4Ilst);
|
||||
let mut tag = Self::new(TagType::MP4ilst);
|
||||
|
||||
for atom in input.atoms {
|
||||
let Atom { ident, data } = atom;
|
||||
|
@ -301,7 +301,7 @@ impl From<Ilst> for Tag {
|
|||
};
|
||||
|
||||
let key = ItemKey::from_key(
|
||||
TagType::Mp4Ilst,
|
||||
TagType::MP4ilst,
|
||||
&match ident {
|
||||
AtomIdent::Fourcc(fourcc) => {
|
||||
fourcc.iter().map(|b| *b as char).collect::<String>()
|
||||
|
@ -392,7 +392,7 @@ impl From<Tag> for Ilst {
|
|||
}
|
||||
|
||||
fn item_key_to_ident(key: &ItemKey) -> Option<AtomIdentRef<'_>> {
|
||||
key.map_key(TagType::Mp4Ilst, true).and_then(|ident| {
|
||||
key.map_key(TagType::MP4ilst, true).and_then(|ident| {
|
||||
if ident.starts_with("----") {
|
||||
let mut split = ident.split(':');
|
||||
|
||||
|
@ -528,7 +528,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn tag_to_ilst() {
|
||||
let mut tag = crate::tag::utils::test_utils::create_tag(TagType::Mp4Ilst);
|
||||
let mut tag = crate::tag::utils::test_utils::create_tag(TagType::MP4ilst);
|
||||
|
||||
tag.insert_text(ItemKey::DiscNumber, String::from("1"));
|
||||
tag.insert_text(ItemKey::DiscTotal, String::from("2"));
|
||||
|
|
|
@ -91,7 +91,7 @@ impl AudioFile for Mp4File {
|
|||
#[allow(unreachable_code, unused_variables)]
|
||||
fn contains_tag_type(&self, tag_type: TagType) -> bool {
|
||||
#[cfg(feature = "mp4_ilst")]
|
||||
return tag_type == TagType::Mp4Ilst && self.ilst.is_some();
|
||||
return tag_type == TagType::MP4ilst && self.ilst.is_some();
|
||||
|
||||
false
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ pub(crate) fn write_to(file: &mut File, tag: &Tag, file_type: FileType) -> Resul
|
|||
write(file, &mut comments_ref, format)
|
||||
},
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 if file_type == FileType::FLAC => {
|
||||
TagType::ID3v2 if file_type == FileType::FLAC => {
|
||||
// This tag can *only* be removed in this format
|
||||
crate::id3::v2::tag::Id3v2TagRef::empty().write_to(file)
|
||||
},
|
||||
|
|
|
@ -403,19 +403,19 @@ macro_rules! gen_item_keys {
|
|||
gen_item_keys!(
|
||||
MAPS => [
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
[TagType::AiffText, AIFF_TEXT_MAP],
|
||||
[TagType::AIFFText, AIFF_TEXT_MAP],
|
||||
|
||||
#[cfg(feature = "ape")]
|
||||
[TagType::Ape, APE_MAP],
|
||||
[TagType::APE, APE_MAP],
|
||||
|
||||
#[cfg(feature = "id3v2")]
|
||||
[TagType::Id3v2, ID3V2_MAP],
|
||||
[TagType::ID3v2, ID3V2_MAP],
|
||||
|
||||
#[cfg(feature = "mp4_ilst")]
|
||||
[TagType::Mp4Ilst, ILST_MAP],
|
||||
[TagType::MP4ilst, ILST_MAP],
|
||||
|
||||
#[cfg(feature = "riff_info_list")]
|
||||
[TagType::RiffInfo, RIFF_INFO_MAP],
|
||||
[TagType::RIFFInfo, RIFF_INFO_MAP],
|
||||
|
||||
#[cfg(feature = "vorbis_comments")]
|
||||
[TagType::VorbisComments, VORBIS_MAP]
|
||||
|
@ -672,7 +672,7 @@ impl TagItem {
|
|||
|
||||
pub(crate) fn re_map(&self, tag_type: TagType) -> bool {
|
||||
#[cfg(feature = "id3v1")]
|
||||
if tag_type == TagType::Id3v1 {
|
||||
if tag_type == TagType::ID3v1 {
|
||||
use crate::id3::v1::constants::VALID_ITEMKEYS;
|
||||
|
||||
return VALID_ITEMKEYS.contains(&self.item_key);
|
||||
|
|
|
@ -59,7 +59,7 @@ macro_rules! impl_accessor {
|
|||
/// ```rust
|
||||
/// use lofty::{Accessor, Tag, TagType};
|
||||
///
|
||||
/// let tag = Tag::new(TagType::Id3v2);
|
||||
/// let tag = Tag::new(TagType::ID3v2);
|
||||
///
|
||||
/// // There are multiple quick getter methods for common items
|
||||
///
|
||||
|
@ -74,7 +74,7 @@ macro_rules! impl_accessor {
|
|||
/// ```rust
|
||||
/// use lofty::{ItemKey, Tag, TagType};
|
||||
///
|
||||
/// let tag = Tag::new(TagType::Id3v2);
|
||||
/// let tag = Tag::new(TagType::ID3v2);
|
||||
///
|
||||
/// // If the type of an item is known, there are getter methods
|
||||
/// // to prevent having to match against the value
|
||||
|
@ -92,7 +92,7 @@ macro_rules! impl_accessor {
|
|||
/// // Converting between formats is as simple as an `into` call.
|
||||
/// // However, such conversions can potentially be *very* lossy.
|
||||
///
|
||||
/// let tag = Tag::new(TagType::Id3v2);
|
||||
/// let tag = Tag::new(TagType::ID3v2);
|
||||
/// let id3v2_tag: Id3v2Tag = tag.into();
|
||||
/// ```
|
||||
pub struct Tag {
|
||||
|
@ -408,25 +408,24 @@ impl TagExt for Tag {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Properly capitalize these
|
||||
/// The tag's format
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum TagType {
|
||||
/// This covers both APEv1 and APEv2 as it doesn't matter much
|
||||
Ape,
|
||||
APE,
|
||||
/// Represents an ID3v1 tag
|
||||
Id3v1,
|
||||
ID3v1,
|
||||
/// This covers all ID3v2 versions since they all get upgraded to ID3v2.4
|
||||
Id3v2,
|
||||
/// Represents an MP4 ILST atom
|
||||
Mp4Ilst,
|
||||
ID3v2,
|
||||
/// Represents an MP4 ilst atom
|
||||
MP4ilst,
|
||||
/// Represents vorbis comments
|
||||
VorbisComments,
|
||||
/// Represents a RIFF INFO LIST
|
||||
RiffInfo,
|
||||
RIFFInfo,
|
||||
/// Represents AIFF text chunks
|
||||
AiffText,
|
||||
AIFFText,
|
||||
}
|
||||
|
||||
impl TagType {
|
||||
|
@ -456,7 +455,7 @@ impl TagType {
|
|||
};
|
||||
|
||||
let special_exceptions =
|
||||
(file_type == FileType::APE || file_type == FileType::FLAC) && *self == TagType::Id3v2;
|
||||
(file_type == FileType::APE || file_type == FileType::FLAC) && *self == TagType::ID3v2;
|
||||
|
||||
if !special_exceptions && !file_type.supports_tag_type(*self) {
|
||||
return Err(LoftyError::new(ErrorKind::UnsupportedTag));
|
||||
|
|
|
@ -45,21 +45,21 @@ pub(crate) fn write_tag(tag: &Tag, file: &mut File, file_type: FileType) -> Resu
|
|||
pub(crate) fn dump_tag<W: Write>(tag: &Tag, writer: &mut W) -> Result<()> {
|
||||
match tag.tag_type() {
|
||||
#[cfg(feature = "ape")]
|
||||
TagType::Ape => ApeTagRef {
|
||||
TagType::APE => ApeTagRef {
|
||||
read_only: false,
|
||||
items: ape::tag::tagitems_into_ape(tag.items()),
|
||||
}
|
||||
.dump_to(writer),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::Id3v1 => Into::<Id3v1TagRef<'_>>::into(tag).dump_to(writer),
|
||||
TagType::ID3v1 => Into::<Id3v1TagRef<'_>>::into(tag).dump_to(writer),
|
||||
#[cfg(feature = "id3v2")]
|
||||
TagType::Id3v2 => Id3v2TagRef {
|
||||
TagType::ID3v2 => Id3v2TagRef {
|
||||
flags: Id3v2TagFlags::default(),
|
||||
frames: v2::tag::tag_frames(tag),
|
||||
}
|
||||
.dump_to(writer),
|
||||
#[cfg(feature = "mp4_ilst")]
|
||||
TagType::Mp4Ilst => Into::<Ilst>::into(tag.clone()).as_ref().dump_to(writer),
|
||||
TagType::MP4ilst => Into::<Ilst>::into(tag.clone()).as_ref().dump_to(writer),
|
||||
#[cfg(feature = "vorbis_comments")]
|
||||
TagType::VorbisComments => {
|
||||
let (vendor, items, pictures) = create_vorbis_comments_ref(tag);
|
||||
|
@ -72,12 +72,12 @@ pub(crate) fn dump_tag<W: Write>(tag: &Tag, writer: &mut W) -> Result<()> {
|
|||
.dump_to(writer)
|
||||
},
|
||||
#[cfg(feature = "riff_info_list")]
|
||||
TagType::RiffInfo => RiffInfoListRef {
|
||||
TagType::RIFFInfo => RiffInfoListRef {
|
||||
items: iff::wav::tag::tagitems_into_riff(tag.items()),
|
||||
}
|
||||
.dump_to(writer),
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
TagType::AiffText => {
|
||||
TagType::AIFFText => {
|
||||
use crate::tag::item::ItemKey;
|
||||
|
||||
AiffTextChunksRef {
|
||||
|
|
|
@ -12,7 +12,7 @@ macro_rules! accessor_trait {
|
|||
///
|
||||
/// ```rust
|
||||
/// use lofty::{Tag, Accessor};
|
||||
/// # let tag_type = lofty::TagType::Id3v2;
|
||||
/// # let tag_type = lofty::TagType::ID3v2;
|
||||
///
|
||||
/// let mut tag = Tag::new(tag_type);
|
||||
///
|
||||
|
@ -24,7 +24,7 @@ macro_rules! accessor_trait {
|
|||
///
|
||||
/// ```rust
|
||||
/// use lofty::{Tag, Accessor};
|
||||
/// # let tag_type = lofty::TagType::Id3v2;
|
||||
/// # let tag_type = lofty::TagType::ID3v2;
|
||||
///
|
||||
#[doc = "let mut tag = Tag::new(tag_type);\ntag.set_" $name "(String::from(\"Foo " $name "\"));"]
|
||||
///
|
||||
|
@ -37,7 +37,7 @@ macro_rules! accessor_trait {
|
|||
///
|
||||
/// ```rust
|
||||
/// use lofty::{Tag, Accessor};
|
||||
/// # let tag_type = lofty::TagType::Id3v2;
|
||||
/// # let tag_type = lofty::TagType::ID3v2;
|
||||
///
|
||||
#[doc = "let mut tag = Tag::new(tag_type);\ntag.set_" $name "(String::from(\"Foo " $name "\"));"]
|
||||
///
|
||||
|
@ -80,7 +80,7 @@ pub trait TagExt: Accessor + Into<Tag> + Sized {
|
|||
///
|
||||
/// ```rust
|
||||
/// use lofty::{Accessor, Tag, TagExt};
|
||||
/// # let tag_type = lofty::TagType::Id3v2;
|
||||
/// # let tag_type = lofty::TagType::ID3v2;
|
||||
///
|
||||
/// let mut tag = Tag::new(tag_type);
|
||||
/// assert!(tag.is_empty());
|
||||
|
|
|
@ -75,9 +75,9 @@ impl AudioFile for WavPackFile {
|
|||
fn contains_tag_type(&self, tag_type: TagType) -> bool {
|
||||
match tag_type {
|
||||
#[cfg(feature = "ape")]
|
||||
TagType::Ape => self.ape_tag.is_some(),
|
||||
TagType::APE => self.ape_tag.is_some(),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::Id3v1 => self.id3v1_tag.is_some(),
|
||||
TagType::ID3v1 => self.id3v1_tag.is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ use std::fs::File;
|
|||
pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
|
||||
match tag.tag_type() {
|
||||
#[cfg(feature = "ape")]
|
||||
TagType::Ape => ape::tag::ApeTagRef {
|
||||
TagType::APE => ape::tag::ApeTagRef {
|
||||
read_only: false,
|
||||
items: ape::tag::tagitems_into_ape(tag.items()),
|
||||
}
|
||||
.write_to(data),
|
||||
#[cfg(feature = "id3v1")]
|
||||
TagType::Id3v1 => Into::<v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(data),
|
||||
TagType::ID3v1 => Into::<v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(data),
|
||||
_ => Err(LoftyError::new(ErrorKind::UnsupportedTag)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ fn read() {
|
|||
crate::verify_artist!(file, primary_tag, "Foo artist", 1);
|
||||
|
||||
// Now verify the text chunks
|
||||
crate::verify_artist!(file, tag, TagType::AiffText, "Bar artist", 1);
|
||||
crate::verify_artist!(file, tag, TagType::AIFFText, "Bar artist", 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -28,7 +28,7 @@ fn write() {
|
|||
crate::set_artist!(tagged_file, primary_tag_mut, "Foo artist", 1 => file, "Bar artist");
|
||||
|
||||
// Text chunks
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::AiffText, "Bar artist", 1 => file, "Baz artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::AIFFText, "Bar artist", 1 => file, "Baz artist");
|
||||
|
||||
// Now reread the file
|
||||
file.rewind().unwrap();
|
||||
|
@ -36,18 +36,18 @@ fn write() {
|
|||
|
||||
crate::set_artist!(tagged_file, primary_tag_mut, "Bar artist", 1 => file, "Foo artist");
|
||||
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::AiffText, "Baz artist", 1 => file, "Bar artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::AIFFText, "Baz artist", 1 => file, "Bar artist");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_text_chunks() {
|
||||
crate::remove_tag!(
|
||||
"tests/files/assets/minimal/full_test.aiff",
|
||||
TagType::AiffText
|
||||
TagType::AIFFText
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_id3v2() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.aiff", TagType::Id3v2);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.aiff", TagType::ID3v2);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ fn read() {
|
|||
crate::verify_artist!(file, primary_tag, "Foo artist", 1);
|
||||
|
||||
// Now verify ID3v1
|
||||
crate::verify_artist!(file, tag, TagType::Id3v1, "Bar artist", 1);
|
||||
crate::verify_artist!(file, tag, TagType::ID3v1, "Bar artist", 1);
|
||||
|
||||
// Finally, verify ID3v2
|
||||
crate::verify_artist!(file, tag, TagType::Id3v2, "Baz artist", 1);
|
||||
crate::verify_artist!(file, tag, TagType::ID3v2, "Baz artist", 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -32,7 +32,7 @@ fn write() {
|
|||
crate::set_artist!(tagged_file, primary_tag_mut, "Foo artist", 1 => file, "Bar artist");
|
||||
|
||||
// ID3v1
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Id3v1, "Bar artist", 1 => file, "Baz artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::ID3v1, "Bar artist", 1 => file, "Baz artist");
|
||||
|
||||
// Now reread the file
|
||||
file.rewind().unwrap();
|
||||
|
@ -40,20 +40,20 @@ fn write() {
|
|||
|
||||
crate::set_artist!(tagged_file, primary_tag_mut, "Bar artist", 1 => file, "Foo artist");
|
||||
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Id3v1, "Baz artist", 1 => file, "Bar artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::ID3v1, "Baz artist", 1 => file, "Bar artist");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_ape() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.ape", TagType::Ape);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.ape", TagType::APE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_id3v1() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.ape", TagType::Id3v1);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.ape", TagType::ID3v1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_id3v2() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.ape", TagType::Id3v2);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.ape", TagType::ID3v2);
|
||||
}
|
||||
|
|
|
@ -23,20 +23,20 @@ fn write() {
|
|||
assert_eq!(tagged_file.file_type(), FileType::MP4);
|
||||
|
||||
// ilst
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Mp4Ilst, "Foo artist", 1 => file, "Bar artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::MP4ilst, "Foo artist", 1 => file, "Bar artist");
|
||||
|
||||
// Now reread the file
|
||||
file.rewind().unwrap();
|
||||
|
||||
let mut tagged_file = lofty::read_from(&mut file, false).unwrap();
|
||||
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Mp4Ilst, "Bar artist", 1 => file, "Foo artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::MP4ilst, "Bar artist", 1 => file, "Foo artist");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove() {
|
||||
crate::remove_tag!(
|
||||
"tests/files/assets/minimal/m4a_codec_aac.m4a",
|
||||
TagType::Mp4Ilst
|
||||
TagType::MP4ilst
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ fn read() {
|
|||
crate::verify_artist!(file, primary_tag, "Foo artist", 1);
|
||||
|
||||
// Now verify ID3v1
|
||||
crate::verify_artist!(file, tag, TagType::Id3v1, "Bar artist", 1);
|
||||
crate::verify_artist!(file, tag, TagType::ID3v1, "Bar artist", 1);
|
||||
|
||||
// Finally, verify APEv2
|
||||
crate::verify_artist!(file, tag, TagType::Ape, "Baz artist", 1);
|
||||
crate::verify_artist!(file, tag, TagType::APE, "Baz artist", 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -55,10 +55,10 @@ fn write() {
|
|||
crate::set_artist!(tagged_file, primary_tag_mut, "Foo artist", 1 => file, "Bar artist");
|
||||
|
||||
// ID3v1
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Id3v1, "Bar artist", 1 => file, "Baz artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::ID3v1, "Bar artist", 1 => file, "Baz artist");
|
||||
|
||||
// APEv2
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Ape, "Baz artist", 1 => file, "Qux artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::APE, "Baz artist", 1 => file, "Qux artist");
|
||||
|
||||
// Now reread the file
|
||||
file.rewind().unwrap();
|
||||
|
@ -66,22 +66,22 @@ fn write() {
|
|||
|
||||
crate::set_artist!(tagged_file, primary_tag_mut, "Bar artist", 1 => file, "Foo artist");
|
||||
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Id3v1, "Baz artist", 1 => file, "Bar artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::ID3v1, "Baz artist", 1 => file, "Bar artist");
|
||||
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::Ape, "Qux artist", 1 => file, "Baz artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::APE, "Qux artist", 1 => file, "Baz artist");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_id3v2() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.mp3", TagType::Id3v2);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.mp3", TagType::ID3v2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_id3v1() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.mp3", TagType::Id3v1);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.mp3", TagType::ID3v1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_ape() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.mp3", TagType::Ape);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.mp3", TagType::APE);
|
||||
}
|
||||
|
|
|
@ -138,5 +138,5 @@ fn flac_with_id3v2() {
|
|||
|
||||
#[test]
|
||||
fn flac_remove_id3v2() {
|
||||
crate::remove_tag!("tests/files/assets/flac_with_id3v2.flac", TagType::Id3v2);
|
||||
crate::remove_tag!("tests/files/assets/flac_with_id3v2.flac", TagType::ID3v2);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ fn read() {
|
|||
crate::verify_artist!(file, primary_tag, "Foo artist", 1);
|
||||
|
||||
// Now verify the RIFF INFO chunk
|
||||
crate::verify_artist!(file, tag, TagType::RiffInfo, "Bar artist", 1);
|
||||
crate::verify_artist!(file, tag, TagType::RIFFInfo, "Bar artist", 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -29,7 +29,7 @@ fn write() {
|
|||
crate::set_artist!(tagged_file, primary_tag_mut, "Foo artist", 1 => file, "Bar artist");
|
||||
|
||||
// RIFF INFO
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::RiffInfo, "Bar artist", 1 => file, "Baz artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::RIFFInfo, "Bar artist", 1 => file, "Baz artist");
|
||||
|
||||
// Now reread the file
|
||||
file.rewind().unwrap();
|
||||
|
@ -37,14 +37,14 @@ fn write() {
|
|||
|
||||
crate::set_artist!(tagged_file, primary_tag_mut, "Bar artist", 1 => file, "Foo artist");
|
||||
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::RiffInfo, "Baz artist", 1 => file, "Bar artist");
|
||||
crate::set_artist!(tagged_file, tag_mut, TagType::RIFFInfo, "Baz artist", 1 => file, "Bar artist");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_id3v2() {
|
||||
crate::remove_tag!(
|
||||
"tests/files/assets/minimal/wav_format_pcm.wav",
|
||||
TagType::Id3v2
|
||||
TagType::ID3v2
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,6 @@ fn remove_id3v2() {
|
|||
fn remove_riff_info() {
|
||||
crate::remove_tag!(
|
||||
"tests/files/assets/minimal/wav_format_pcm.wav",
|
||||
TagType::RiffInfo
|
||||
TagType::RIFFInfo
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ fn read() {
|
|||
crate::verify_artist!(file, primary_tag, "Foo artist", 1);
|
||||
|
||||
// Now verify the ID3v1 tag
|
||||
crate::verify_artist!(file, tag, TagType::Id3v1, "Bar artist", 1);
|
||||
crate::verify_artist!(file, tag, TagType::ID3v1, "Bar artist", 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -28,7 +28,7 @@ fn write() {
|
|||
set_artist!(tagged_file, primary_tag_mut, "Foo artist", 1 => file, "Bar artist");
|
||||
|
||||
// ID3v1
|
||||
set_artist!(tagged_file, tag_mut, TagType::Id3v1, "Bar artist", 1 => file, "Baz artist");
|
||||
set_artist!(tagged_file, tag_mut, TagType::ID3v1, "Bar artist", 1 => file, "Baz artist");
|
||||
|
||||
// Now reread the file
|
||||
file.rewind().unwrap();
|
||||
|
@ -36,15 +36,15 @@ fn write() {
|
|||
|
||||
set_artist!(tagged_file, primary_tag_mut, "Bar artist", 1 => file, "Foo artist");
|
||||
|
||||
set_artist!(tagged_file, tag_mut, TagType::Id3v1, "Baz artist", 1 => file, "Bar artist");
|
||||
set_artist!(tagged_file, tag_mut, TagType::ID3v1, "Baz artist", 1 => file, "Bar artist");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_id3v1() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.wv", TagType::Id3v1);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.wv", TagType::ID3v1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_ape() {
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.wv", TagType::Ape);
|
||||
crate::remove_tag!("tests/files/assets/minimal/full_test.wv", TagType::APE);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use lofty::{ItemKey, Tag, TagType};
|
|||
|
||||
#[test]
|
||||
fn tag_to_id3v2_lang_frame() {
|
||||
let mut tag = Tag::new(TagType::Id3v2);
|
||||
let mut tag = Tag::new(TagType::ID3v2);
|
||||
tag.insert_text(ItemKey::Lyrics, String::from("Test lyrics"));
|
||||
tag.insert_text(ItemKey::Comment, String::from("Test comment"));
|
||||
|
||||
|
|
Loading…
Reference in a new issue