ID3v2: Rename ID3v2Tag to Id3v2Tag

This commit is contained in:
Serial 2023-04-28 01:55:40 -04:00 committed by Alex
parent af490d0caf
commit cb01e82d07
20 changed files with 98 additions and 98 deletions

View file

@ -1,6 +1,6 @@
use lofty::ape::ApeTag; use lofty::ape::ApeTag;
use lofty::id3::v1::ID3v1Tag; use lofty::id3::v1::ID3v1Tag;
use lofty::id3::v2::ID3v2Tag; use lofty::id3::v2::Id3v2Tag;
use lofty::iff::aiff::AIFFTextChunks; use lofty::iff::aiff::AIFFTextChunks;
use lofty::iff::wav::RIFFInfoList; use lofty::iff::wav::RIFFInfoList;
use lofty::mp4::Ilst; use lofty::mp4::Ilst;
@ -36,7 +36,7 @@ fn bench_write(c: &mut Criterion) {
[ [
("AIFF Text Chunks", AIFFTextChunks), ("AIFF Text Chunks", AIFFTextChunks),
("APEv2", ApeTag), ("APEv2", ApeTag),
("ID3v2", ID3v2Tag), ("ID3v2", Id3v2Tag),
("ID3v1", ID3v1Tag), ("ID3v1", ID3v1Tag),
("MP4 Ilst", Ilst), ("MP4 Ilst", Ilst),
("RIFF INFO", RIFFInfoList), ("RIFF INFO", RIFFInfoList),

View file

@ -1,6 +1,6 @@
use lofty::ape::ApeTag; use lofty::ape::ApeTag;
use lofty::error::Result as LoftyResult; use lofty::error::Result as LoftyResult;
use lofty::id3::v2::ID3v2Tag; use lofty::id3::v2::Id3v2Tag;
use lofty::resolve::FileResolver; use lofty::resolve::FileResolver;
use lofty::{FileProperties, FileType, ParseOptions, TagType}; use lofty::{FileProperties, FileType, ParseOptions, TagType};
use lofty_attr::LoftyFile; use lofty_attr::LoftyFile;
@ -26,7 +26,7 @@ struct MyFile {
// Specify a tag type // Specify a tag type
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
// Let's say our file *always* has an ID3v2Tag present. // Let's say our file *always* has an ID3v2Tag present.
pub id3v2_tag: ID3v2Tag, pub id3v2_tag: Id3v2Tag,
// Our APE tag is optional in this format, so we wrap it in an `Option` // Our APE tag is optional in this format, so we wrap it in an `Option`
#[lofty(tag_type = "Ape")] #[lofty(tag_type = "Ape")]
@ -45,7 +45,7 @@ impl MyFile {
// Your parsing logic... // Your parsing logic...
Ok(Self { Ok(Self {
id3v2_tag: ID3v2Tag::default(), id3v2_tag: Id3v2Tag::default(),
ape_tag: None, ape_tag: None,
properties: FileProperties::default(), properties: FileProperties::default(),
}) })

View file

@ -7,7 +7,7 @@ mod properties;
mod read; mod read;
use crate::id3::v1::tag::ID3v1Tag; use crate::id3::v1::tag::ID3v1Tag;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use lofty_attr::LoftyFile; use lofty_attr::LoftyFile;
@ -21,7 +21,7 @@ pub use properties::AACProperties;
#[lofty(internal_write_module_do_not_use_anywhere_else)] #[lofty(internal_write_module_do_not_use_anywhere_else)]
pub struct AacFile { pub struct AacFile {
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<ID3v2Tag>, pub(crate) id3v2_tag: Option<Id3v2Tag>,
#[lofty(tag_type = "Id3v1")] #[lofty(tag_type = "Id3v1")]
pub(crate) id3v1_tag: Option<ID3v1Tag>, pub(crate) id3v1_tag: Option<ID3v1Tag>,
pub(crate) properties: AACProperties, pub(crate) properties: AACProperties,

View file

@ -12,7 +12,7 @@ mod read;
pub(crate) mod tag; pub(crate) mod tag;
use crate::id3::v1::tag::ID3v1Tag; use crate::id3::v1::tag::ID3v1Tag;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use lofty_attr::LoftyFile; use lofty_attr::LoftyFile;
@ -33,7 +33,7 @@ pub struct ApeFile {
pub(crate) id3v1_tag: Option<ID3v1Tag>, pub(crate) id3v1_tag: Option<ID3v1Tag>,
/// An ID3v2 tag (Not officially supported) /// An ID3v2 tag (Not officially supported)
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<ID3v2Tag>, pub(crate) id3v2_tag: Option<Id3v2Tag>,
/// An APEv1/v2 tag /// An APEv1/v2 tag
#[lofty(tag_type = "Ape")] #[lofty(tag_type = "Ape")]
pub(crate) ape_tag: Option<ApeTag>, pub(crate) ape_tag: Option<ApeTag>,

View file

@ -6,7 +6,7 @@ use super::{ApeFile, ApeProperties};
use crate::error::Result; use crate::error::Result;
use crate::id3::v1::tag::ID3v1Tag; use crate::id3::v1::tag::ID3v1Tag;
use crate::id3::v2::read::parse_id3v2; use crate::id3::v2::read::parse_id3v2;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, ID3FindResults}; use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, ID3FindResults};
use crate::macros::decode_err; use crate::macros::decode_err;
use crate::probe::ParseOptions; use crate::probe::ParseOptions;
@ -24,7 +24,7 @@ where
let mut stream_len = end - start; let mut stream_len = end - start;
let mut id3v2_tag: Option<ID3v2Tag> = None; let mut id3v2_tag: Option<Id3v2Tag> = None;
let mut id3v1_tag: Option<ID3v1Tag> = None; let mut id3v1_tag: Option<ID3v1Tag> = None;
let mut ape_tag: Option<ApeTag> = None; let mut ape_tag: Option<ApeTag> = None;

View file

@ -11,7 +11,7 @@ pub(crate) mod write;
use crate::error::Result; use crate::error::Result;
use crate::file::{FileType, TaggedFile}; use crate::file::{FileType, TaggedFile};
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use crate::ogg::tag::VorbisCommentsRef; use crate::ogg::tag::VorbisCommentsRef;
use crate::ogg::{OggPictureStorage, VorbisComments}; use crate::ogg::{OggPictureStorage, VorbisComments};
use crate::picture::{Picture, PictureInformation}; use crate::picture::{Picture, PictureInformation};
@ -44,7 +44,7 @@ pub use properties::FlacProperties;
pub struct FlacFile { pub struct FlacFile {
/// An ID3v2 tag /// An ID3v2 tag
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<ID3v2Tag>, pub(crate) id3v2_tag: Option<Id3v2Tag>,
/// The vorbis comments contained in the file /// The vorbis comments contained in the file
#[lofty(tag_type = "VorbisComments")] #[lofty(tag_type = "VorbisComments")]
pub(crate) vorbis_comments_tag: Option<VorbisComments>, pub(crate) vorbis_comments_tag: Option<VorbisComments>,

View file

@ -4,7 +4,7 @@
//! //!
//! See: //! See:
//! //!
//! * [`ID3v2Tag`] //! * [`Id3v2Tag`]
//! * [Frame] //! * [Frame]
mod flags; mod flags;
@ -29,7 +29,7 @@ use byteorder::{BigEndian, ByteOrder, ReadBytesExt};
pub use flags::ID3v2TagFlags; pub use flags::ID3v2TagFlags;
pub use util::upgrade::{upgrade_v2, upgrade_v3}; pub use util::upgrade::{upgrade_v2, upgrade_v3};
pub use tag::ID3v2Tag; pub use tag::Id3v2Tag;
pub use items::*; pub use items::*;

View file

@ -1,12 +1,12 @@
use super::frame::Frame; use super::frame::Frame;
use super::tag::ID3v2Tag; use super::tag::Id3v2Tag;
use super::ID3v2Header; use super::ID3v2Header;
use crate::error::Result; use crate::error::Result;
use crate::id3::v2::util::synchsafe::UnsynchronizedStream; use crate::id3::v2::util::synchsafe::UnsynchronizedStream;
use std::io::Read; use std::io::Read;
pub(crate) fn parse_id3v2<R>(bytes: &mut R, header: ID3v2Header) -> Result<ID3v2Tag> pub(crate) fn parse_id3v2<R>(bytes: &mut R, header: ID3v2Header) -> Result<Id3v2Tag>
where where
R: Read, R: Read,
{ {
@ -29,11 +29,11 @@ where
Ok(ret) Ok(ret)
} }
fn read_all_frames_into_tag<R>(reader: &mut R, header: ID3v2Header) -> Result<ID3v2Tag> fn read_all_frames_into_tag<R>(reader: &mut R, header: ID3v2Header) -> Result<Id3v2Tag>
where where
R: Read, R: Read,
{ {
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.original_version = header.version; tag.original_version = header.version;
tag.set_flags(header.flags); tag.set_flags(header.flags);

View file

@ -98,13 +98,13 @@ macro_rules! impl_accessor {
description = "An `ID3v2` tag", description = "An `ID3v2` tag",
supported_formats(Aac, Aiff, Mpeg, Wav, read_only(Flac, Ape)) supported_formats(Aac, Aiff, Mpeg, Wav, read_only(Flac, Ape))
)] )]
pub struct ID3v2Tag { pub struct Id3v2Tag {
flags: ID3v2TagFlags, flags: ID3v2TagFlags,
pub(super) original_version: ID3v2Version, pub(super) original_version: ID3v2Version,
pub(crate) frames: Vec<Frame<'static>>, pub(crate) frames: Vec<Frame<'static>>,
} }
impl IntoIterator for ID3v2Tag { impl IntoIterator for Id3v2Tag {
type Item = Frame<'static>; type Item = Frame<'static>;
type IntoIter = std::vec::IntoIter<Self::Item>; type IntoIter = std::vec::IntoIter<Self::Item>;
@ -113,7 +113,7 @@ impl IntoIterator for ID3v2Tag {
} }
} }
impl<'a> IntoIterator for &'a ID3v2Tag { impl<'a> IntoIterator for &'a Id3v2Tag {
type Item = &'a Frame<'static>; type Item = &'a Frame<'static>;
type IntoIter = std::slice::Iter<'a, Frame<'static>>; type IntoIter = std::slice::Iter<'a, Frame<'static>>;
@ -122,7 +122,7 @@ impl<'a> IntoIterator for &'a ID3v2Tag {
} }
} }
impl Default for ID3v2Tag { impl Default for Id3v2Tag {
fn default() -> Self { fn default() -> Self {
Self { Self {
flags: ID3v2TagFlags::default(), flags: ID3v2TagFlags::default(),
@ -132,16 +132,16 @@ impl Default for ID3v2Tag {
} }
} }
impl ID3v2Tag { impl Id3v2Tag {
/// Create a new empty `ID3v2Tag` /// Create a new empty `ID3v2Tag`
/// ///
/// # Examples /// # Examples
/// ///
/// ```rust /// ```rust
/// use lofty::id3::v2::ID3v2Tag; /// use lofty::id3::v2::Id3v2Tag;
/// use lofty::TagExt; /// use lofty::TagExt;
/// ///
/// let id3v2_tag = ID3v2Tag::new(); /// let id3v2_tag = Id3v2Tag::new();
/// assert!(id3v2_tag.is_empty()); /// assert!(id3v2_tag.is_empty());
/// ``` /// ```
pub fn new() -> Self { pub fn new() -> Self {
@ -167,7 +167,7 @@ impl ID3v2Tag {
} }
} }
impl ID3v2Tag { impl Id3v2Tag {
/// Gets a [`Frame`] from an id /// Gets a [`Frame`] from an id
/// ///
/// NOTE: This is *not* case-sensitive /// NOTE: This is *not* case-sensitive
@ -437,7 +437,7 @@ where
} }
} }
impl Accessor for ID3v2Tag { impl Accessor for Id3v2Tag {
impl_accessor!( impl_accessor!(
title => "TIT2"; title => "TIT2";
artist => "TPE1"; artist => "TPE1";
@ -558,7 +558,7 @@ impl Accessor for ID3v2Tag {
} }
} }
impl TagExt for ID3v2Tag { impl TagExt for Id3v2Tag {
type Err = LoftyError; type Err = LoftyError;
type RefKey<'a> = &'a FrameId<'a>; type RefKey<'a> = &'a FrameId<'a>;
@ -617,23 +617,23 @@ impl TagExt for ID3v2Tag {
} }
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub struct SplitTagRemainder(ID3v2Tag); pub struct SplitTagRemainder(Id3v2Tag);
impl From<SplitTagRemainder> for ID3v2Tag { impl From<SplitTagRemainder> for Id3v2Tag {
fn from(from: SplitTagRemainder) -> Self { fn from(from: SplitTagRemainder) -> Self {
from.0 from.0
} }
} }
impl Deref for SplitTagRemainder { impl Deref for SplitTagRemainder {
type Target = ID3v2Tag; type Target = Id3v2Tag;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&self.0 &self.0
} }
} }
impl SplitTag for ID3v2Tag { impl SplitTag for Id3v2Tag {
type Remainder = SplitTagRemainder; type Remainder = SplitTagRemainder;
fn split_tag(mut self) -> (Self::Remainder, Tag) { fn split_tag(mut self) -> (Self::Remainder, Tag) {
@ -845,9 +845,9 @@ impl SplitTag for ID3v2Tag {
} }
impl MergeTag for SplitTagRemainder { impl MergeTag for SplitTagRemainder {
type Merged = ID3v2Tag; type Merged = Id3v2Tag;
fn merge_tag(self, mut tag: Tag) -> ID3v2Tag { fn merge_tag(self, mut tag: Tag) -> Id3v2Tag {
fn join_text_items<'a>( fn join_text_items<'a>(
tag: &mut Tag, tag: &mut Tag,
keys: impl IntoIterator<Item = &'a ItemKey>, keys: impl IntoIterator<Item = &'a ItemKey>,
@ -981,13 +981,13 @@ impl MergeTag for SplitTagRemainder {
} }
} }
impl From<ID3v2Tag> for Tag { impl From<Id3v2Tag> for Tag {
fn from(input: ID3v2Tag) -> Self { fn from(input: Id3v2Tag) -> Self {
input.split_tag().1 input.split_tag().1
} }
} }
impl From<Tag> for ID3v2Tag { impl From<Tag> for Id3v2Tag {
fn from(input: Tag) -> Self { fn from(input: Tag) -> Self {
SplitTagRemainder::default().merge_tag(input) SplitTagRemainder::default().merge_tag(input)
} }
@ -1077,7 +1077,7 @@ mod tests {
}; };
use crate::id3::v2::{ use crate::id3::v2::{
read_id3v2_header, AttachedPictureFrame, CommentFrame, ExtendedTextFrame, Frame, read_id3v2_header, AttachedPictureFrame, CommentFrame, ExtendedTextFrame, Frame,
FrameFlags, FrameId, FrameValue, ID3v2Tag, ID3v2Version, TextInformationFrame, FrameFlags, FrameId, FrameValue, ID3v2Version, Id3v2Tag, TextInformationFrame,
UrlLinkFrame, UrlLinkFrame,
}; };
use crate::tag::utils::test_utils::read_path; use crate::tag::utils::test_utils::read_path;
@ -1089,7 +1089,7 @@ mod tests {
use super::{COMMENT_FRAME_ID, EMPTY_CONTENT_DESCRIPTOR}; use super::{COMMENT_FRAME_ID, EMPTY_CONTENT_DESCRIPTOR};
fn read_tag(path: &str) -> ID3v2Tag { fn read_tag(path: &str) -> Id3v2Tag {
let tag_bytes = crate::tag::utils::test_utils::read_path(path); let tag_bytes = crate::tag::utils::test_utils::read_path(path);
let mut reader = std::io::Cursor::new(&tag_bytes[..]); let mut reader = std::io::Cursor::new(&tag_bytes[..]);
@ -1100,7 +1100,7 @@ mod tests {
#[test] #[test]
fn parse_id3v2() { fn parse_id3v2() {
let mut expected_tag = ID3v2Tag::default(); let mut expected_tag = Id3v2Tag::default();
let encoding = TextEncoding::Latin1; let encoding = TextEncoding::Latin1;
let flags = FrameFlags::default(); let flags = FrameFlags::default();
@ -1254,7 +1254,7 @@ mod tests {
counter: 65535, counter: 65535,
}; };
let converted_tag: ID3v2Tag = tag.into(); let converted_tag: Id3v2Tag = tag.into();
assert_eq!(converted_tag.frames.len(), 1); assert_eq!(converted_tag.frames.len(), 1);
let actual_frame = converted_tag.frames.first().unwrap(); let actual_frame = converted_tag.frames.first().unwrap();
@ -1274,7 +1274,7 @@ mod tests {
#[test] #[test]
fn fail_write_bad_frame() { fn fail_write_bad_frame() {
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.insert(Frame { tag.insert(Frame {
id: FrameId::Valid(Cow::Borrowed("ABCD")), id: FrameId::Valid(Cow::Borrowed("ABCD")),
value: FrameValue::Url(UrlLinkFrame(String::from("FOO URL"))), value: FrameValue::Url(UrlLinkFrame(String::from("FOO URL"))),
@ -1294,7 +1294,7 @@ mod tests {
#[test] #[test]
fn tag_to_id3v2() { fn tag_to_id3v2() {
fn verify_frame(tag: &ID3v2Tag, id: &str, value: &str) { fn verify_frame(tag: &Id3v2Tag, id: &str, value: &str) {
let frame = tag.get(id); let frame = tag.get(id);
assert!(frame.is_some()); assert!(frame.is_some());
@ -1312,7 +1312,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(); let id3v2_tag: Id3v2Tag = tag.into();
verify_frame(&id3v2_tag, "TIT2", "Foo title"); verify_frame(&id3v2_tag, "TIT2", "Foo title");
verify_frame(&id3v2_tag, "TPE1", "Bar artist"); verify_frame(&id3v2_tag, "TPE1", "Bar artist");
@ -1334,8 +1334,8 @@ mod tests {
} }
#[allow(clippy::field_reassign_with_default)] #[allow(clippy::field_reassign_with_default)]
fn create_full_test_tag(version: ID3v2Version) -> ID3v2Tag { fn create_full_test_tag(version: ID3v2Version) -> Id3v2Tag {
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.original_version = version; tag.original_version = version;
let encoding = TextEncoding::UTF16; let encoding = TextEncoding::UTF16;
@ -1518,7 +1518,7 @@ mod tests {
#[test] #[test]
fn multi_value_frame_to_tag() { fn multi_value_frame_to_tag() {
use crate::traits::Accessor; use crate::traits::Accessor;
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.set_artist(String::from("foo\0bar\0baz")); tag.set_artist(String::from("foo\0bar\0baz"));
@ -1545,7 +1545,7 @@ mod tests {
ItemValue::Text(String::from("baz")), ItemValue::Text(String::from("baz")),
)); ));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.artist().as_deref(), Some("foo/bar/baz")) assert_eq!(tag.artist().as_deref(), Some("foo/bar/baz"))
} }
@ -1556,7 +1556,7 @@ mod tests {
#[test] #[test]
fn replaygain_tag_conversion() { fn replaygain_tag_conversion() {
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.insert( tag.insert(
Frame::new( Frame::new(
"TXXX", "TXXX",
@ -1639,7 +1639,7 @@ mod tests {
)); ));
assert_eq!(20, tag.len()); assert_eq!(20, tag.len());
let id3v2 = ID3v2Tag::from(tag.clone()); let id3v2 = Id3v2Tag::from(tag.clone());
let (split_remainder, split_tag) = id3v2.split_tag(); let (split_remainder, split_tag) = id3v2.split_tag();
assert_eq!(0, split_remainder.0.len()); assert_eq!(0, split_remainder.0.len());
@ -1651,7 +1651,7 @@ mod tests {
#[test] #[test]
fn comments() { fn comments() {
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
let encoding = TextEncoding::Latin1; let encoding = TextEncoding::Latin1;
let flags = FrameFlags::default(); let flags = FrameFlags::default();
let custom_descriptor = "lofty-rs"; let custom_descriptor = "lofty-rs";
@ -1720,7 +1720,7 @@ mod tests {
) )
.unwrap(); .unwrap();
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.insert(txxx_frame.clone()); tag.insert(txxx_frame.clone());
tag.insert(wxxx_frame.clone()); tag.insert(wxxx_frame.clone());
@ -1743,7 +1743,7 @@ mod tests {
.zip(tag.items()) .zip(tag.items())
.all(|(expected, actual)| expected == actual)); .all(|(expected, actual)| expected == actual));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.frames.len(), 2); assert_eq!(tag.frames.len(), 2);
assert_eq!(&tag.frames, &[txxx_frame, wxxx_frame]) assert_eq!(&tag.frames, &[txxx_frame, wxxx_frame])
@ -1751,7 +1751,7 @@ mod tests {
#[test] #[test]
fn user_defined_frames_conversion() { fn user_defined_frames_conversion() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
id3v2.insert( id3v2.insert(
Frame::new( Frame::new(
"TXXX", "TXXX",
@ -1805,7 +1805,7 @@ mod tests {
#[test] #[test]
fn set_track() { fn set_track() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let track = 1; let track = 1;
id3v2.set_track(track); id3v2.set_track(track);
@ -1816,7 +1816,7 @@ mod tests {
#[test] #[test]
fn set_track_total() { fn set_track_total() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let track_total = 2; let track_total = 2;
id3v2.set_track_total(track_total); id3v2.set_track_total(track_total);
@ -1827,7 +1827,7 @@ mod tests {
#[test] #[test]
fn set_track_and_track_total() { fn set_track_and_track_total() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let track = 1; let track = 1;
let track_total = 2; let track_total = 2;
@ -1840,7 +1840,7 @@ mod tests {
#[test] #[test]
fn set_track_total_and_track() { fn set_track_total_and_track() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let track_total = 2; let track_total = 2;
let track = 1; let track = 1;
@ -1853,7 +1853,7 @@ mod tests {
#[test] #[test]
fn set_disk() { fn set_disk() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let disk = 1; let disk = 1;
id3v2.set_disk(disk); id3v2.set_disk(disk);
@ -1864,7 +1864,7 @@ mod tests {
#[test] #[test]
fn set_disk_total() { fn set_disk_total() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let disk_total = 2; let disk_total = 2;
id3v2.set_disk_total(disk_total); id3v2.set_disk_total(disk_total);
@ -1875,7 +1875,7 @@ mod tests {
#[test] #[test]
fn set_disk_and_disk_total() { fn set_disk_and_disk_total() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let disk = 1; let disk = 1;
let disk_total = 2; let disk_total = 2;
@ -1888,7 +1888,7 @@ mod tests {
#[test] #[test]
fn set_disk_total_and_disk() { fn set_disk_total_and_disk() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let disk_total = 2; let disk_total = 2;
let disk = 1; let disk = 1;
@ -1911,7 +1911,7 @@ mod tests {
ItemValue::Text(track_number.to_string()), ItemValue::Text(track_number.to_string()),
)); ));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.track().unwrap(), track_number); assert_eq!(tag.track().unwrap(), track_number);
assert!(tag.track_total().is_none()); assert!(tag.track_total().is_none());
@ -1929,7 +1929,7 @@ mod tests {
ItemValue::Text(track_total.to_string()), ItemValue::Text(track_total.to_string()),
)); ));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.track().unwrap(), DEFAULT_NUMBER_IN_PAIR); assert_eq!(tag.track().unwrap(), DEFAULT_NUMBER_IN_PAIR);
assert_eq!(tag.track_total().unwrap(), track_total); assert_eq!(tag.track_total().unwrap(), track_total);
@ -1953,7 +1953,7 @@ mod tests {
ItemValue::Text(track_total.to_string()), ItemValue::Text(track_total.to_string()),
)); ));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.track().unwrap(), track_number); assert_eq!(tag.track().unwrap(), track_number);
assert_eq!(tag.track_total().unwrap(), track_total); assert_eq!(tag.track_total().unwrap(), track_total);
@ -1971,7 +1971,7 @@ mod tests {
ItemValue::Text(disk_number.to_string()), ItemValue::Text(disk_number.to_string()),
)); ));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.disk().unwrap(), disk_number); assert_eq!(tag.disk().unwrap(), disk_number);
assert!(tag.disk_total().is_none()); assert!(tag.disk_total().is_none());
@ -1989,7 +1989,7 @@ mod tests {
ItemValue::Text(disk_total.to_string()), ItemValue::Text(disk_total.to_string()),
)); ));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.disk().unwrap(), DEFAULT_NUMBER_IN_PAIR); assert_eq!(tag.disk().unwrap(), DEFAULT_NUMBER_IN_PAIR);
assert_eq!(tag.disk_total().unwrap(), disk_total); assert_eq!(tag.disk_total().unwrap(), disk_total);
@ -2013,14 +2013,14 @@ mod tests {
ItemValue::Text(disk_total.to_string()), ItemValue::Text(disk_total.to_string()),
)); ));
let tag: ID3v2Tag = tag.into(); let tag: Id3v2Tag = tag.into();
assert_eq!(tag.disk().unwrap(), disk_number); assert_eq!(tag.disk().unwrap(), disk_number);
assert_eq!(tag.disk_total().unwrap(), disk_total); assert_eq!(tag.disk_total().unwrap(), disk_total);
} }
fn create_tag_with_trck_and_tpos_frame(content: &'static str) -> Tag { fn create_tag_with_trck_and_tpos_frame(content: &'static str) -> Tag {
fn insert_frame(id: &'static str, content: &'static str, tag: &mut ID3v2Tag) { fn insert_frame(id: &'static str, content: &'static str, tag: &mut Id3v2Tag) {
tag.insert(new_text_frame( tag.insert(new_text_frame(
FrameId::Valid(Cow::Borrowed(id)), FrameId::Valid(Cow::Borrowed(id)),
content.to_string(), content.to_string(),
@ -2028,7 +2028,7 @@ mod tests {
)); ));
} }
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
insert_frame("TRCK", content, &mut tag); insert_frame("TRCK", content, &mut tag);
insert_frame("TPOS", content, &mut tag); insert_frame("TPOS", content, &mut tag);
@ -2080,7 +2080,7 @@ mod tests {
#[test] #[test]
fn ufid_frame_with_musicbrainz_record_id() { fn ufid_frame_with_musicbrainz_record_id() {
let mut id3v2 = ID3v2Tag::default(); let mut id3v2 = Id3v2Tag::default();
let unknown_ufid_frame = UniqueFileIdentifierFrame { let unknown_ufid_frame = UniqueFileIdentifierFrame {
owner: "other".to_owned(), owner: "other".to_owned(),
identifier: b"0123456789".to_vec(), identifier: b"0123456789".to_vec(),

View file

@ -8,7 +8,7 @@ use crate::id3::find_id3v2;
use crate::id3::v2::frame::FrameRef; use crate::id3::v2::frame::FrameRef;
use crate::id3::v2::tag::Id3v2TagRef; use crate::id3::v2::tag::Id3v2TagRef;
use crate::id3::v2::util::synchsafe::SynchsafeInteger; use crate::id3::v2::util::synchsafe::SynchsafeInteger;
use crate::id3::v2::ID3v2Tag; use crate::id3::v2::Id3v2Tag;
use crate::macros::err; use crate::macros::err;
use crate::probe::Probe; use crate::probe::Probe;
@ -49,13 +49,13 @@ pub(crate) fn write_id3v2<'a, I: Iterator<Item = FrameRef<'a>> + Clone + 'a>(
let file_type = file_type.unwrap(); let file_type = file_type.unwrap();
if !ID3v2Tag::SUPPORTED_FORMATS.contains(&file_type) { if !Id3v2Tag::SUPPORTED_FORMATS.contains(&file_type) {
err!(UnsupportedTag); err!(UnsupportedTag);
} }
// Attempting to write a non-empty tag to a read only format // Attempting to write a non-empty tag to a read only format
// An empty tag implies the tag should be stripped. // An empty tag implies the tag should be stripped.
if ID3v2Tag::READ_ONLY_FORMATS.contains(&file_type) { if Id3v2Tag::READ_ONLY_FORMATS.contains(&file_type) {
let mut peek = tag.frames.clone().peekable(); let mut peek = tag.frames.clone().peekable();
if peek.peek().is_some() { if peek.peek().is_some() {
err!(UnsupportedTag); err!(UnsupportedTag);
@ -253,12 +253,12 @@ fn calculate_crc(content: &[u8]) -> [u8; 5] {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::id3::v2::{ID3v2Tag, ID3v2TagFlags}; use crate::id3::v2::{ID3v2TagFlags, Id3v2Tag};
use crate::{Accessor, TagExt}; use crate::{Accessor, TagExt};
#[test] #[test]
fn id3v2_write_crc32() { fn id3v2_write_crc32() {
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.set_artist(String::from("Foo artist")); tag.set_artist(String::from("Foo artist"));
let flags = ID3v2TagFlags { let flags = ID3v2TagFlags {

View file

@ -4,7 +4,7 @@ mod properties;
mod read; mod read;
pub(crate) mod tag; pub(crate) mod tag;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use crate::properties::FileProperties; use crate::properties::FileProperties;
use lofty_attr::LoftyFile; use lofty_attr::LoftyFile;
@ -23,7 +23,7 @@ pub struct AiffFile {
pub(crate) text_chunks_tag: Option<AIFFTextChunks>, pub(crate) text_chunks_tag: Option<AIFFTextChunks>,
/// An ID3v2 tag /// An ID3v2 tag
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<ID3v2Tag>, pub(crate) id3v2_tag: Option<Id3v2Tag>,
/// The file's audio properties /// The file's audio properties
pub(crate) properties: FileProperties, pub(crate) properties: FileProperties,
} }

View file

@ -1,7 +1,7 @@
use super::tag::{AIFFTextChunks, Comment}; use super::tag::{AIFFTextChunks, Comment};
use super::AiffFile; use super::AiffFile;
use crate::error::Result; use crate::error::Result;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use crate::iff::chunk::Chunks; use crate::iff::chunk::Chunks;
use crate::macros::{decode_err, err}; use crate::macros::{decode_err, err};
use crate::probe::ParseOptions; use crate::probe::ParseOptions;
@ -45,7 +45,7 @@ where
let mut annotations = Vec::new(); let mut annotations = Vec::new();
let mut comments = Vec::new(); let mut comments = Vec::new();
let mut id3v2_tag: Option<ID3v2Tag> = None; let mut id3v2_tag: Option<Id3v2Tag> = None;
let mut chunks = Chunks::<BigEndian>::new(file_len); let mut chunks = Chunks::<BigEndian>::new(file_len);

View file

@ -1,5 +1,5 @@
use crate::error::Result; use crate::error::Result;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use crate::macros::{err, try_vec}; use crate::macros::{err, try_vec};
use std::io::{Read, Seek, SeekFrom}; use std::io::{Read, Seek, SeekFrom};
@ -91,7 +91,7 @@ impl<B: ByteOrder> Chunks<B> {
Ok(content) Ok(content)
} }
pub fn id3_chunk<R>(&mut self, data: &mut R) -> Result<ID3v2Tag> pub fn id3_chunk<R>(&mut self, data: &mut R) -> Result<Id3v2Tag>
where where
R: Read + Seek, R: Read + Seek,
{ {

View file

@ -4,7 +4,7 @@ mod properties;
mod read; mod read;
pub(crate) mod tag; pub(crate) mod tag;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use lofty_attr::LoftyFile; use lofty_attr::LoftyFile;
@ -22,7 +22,7 @@ pub struct WavFile {
pub(crate) riff_info_tag: Option<RIFFInfoList>, pub(crate) riff_info_tag: Option<RIFFInfoList>,
/// An ID3v2 tag /// An ID3v2 tag
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<ID3v2Tag>, pub(crate) id3v2_tag: Option<Id3v2Tag>,
/// The file's audio properties /// The file's audio properties
pub(crate) properties: WavProperties, pub(crate) properties: WavProperties,
} }

View file

@ -2,7 +2,7 @@ use super::properties::WavProperties;
use super::tag::RIFFInfoList; use super::tag::RIFFInfoList;
use super::WavFile; use super::WavFile;
use crate::error::Result; use crate::error::Result;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use crate::iff::chunk::Chunks; use crate::iff::chunk::Chunks;
use crate::macros::decode_err; use crate::macros::decode_err;
use crate::probe::ParseOptions; use crate::probe::ParseOptions;
@ -45,7 +45,7 @@ where
let mut fmt = Vec::new(); let mut fmt = Vec::new();
let mut riff_info = RIFFInfoList::default(); let mut riff_info = RIFFInfoList::default();
let mut id3v2_tag: Option<ID3v2Tag> = None; let mut id3v2_tag: Option<Id3v2Tag> = None;
let mut chunks = Chunks::<LittleEndian>::new(file_len); let mut chunks = Chunks::<LittleEndian>::new(file_len);

View file

@ -9,7 +9,7 @@ pub use properties::MpegProperties;
use crate::ape::tag::ApeTag; use crate::ape::tag::ApeTag;
use crate::id3::v1::tag::ID3v1Tag; use crate::id3::v1::tag::ID3v1Tag;
use crate::id3::v2::tag::ID3v2Tag; use crate::id3::v2::tag::Id3v2Tag;
use lofty_attr::LoftyFile; use lofty_attr::LoftyFile;
@ -20,7 +20,7 @@ use lofty_attr::LoftyFile;
pub struct MpegFile { pub struct MpegFile {
/// An ID3v2 tag /// An ID3v2 tag
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<ID3v2Tag>, pub(crate) id3v2_tag: Option<Id3v2Tag>,
/// An ID3v1 tag /// An ID3v1 tag
#[lofty(tag_type = "Id3v1")] #[lofty(tag_type = "Id3v1")]
pub(crate) id3v1_tag: Option<ID3v1Tag>, pub(crate) id3v1_tag: Option<ID3v1Tag>,

View file

@ -130,7 +130,7 @@ pub fn register_custom_resolver<T: FileResolver + 'static>(name: &'static str) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::file::{FileType, TaggedFileExt}; use crate::file::{FileType, TaggedFileExt};
use crate::id3::v2::ID3v2Tag; use crate::id3::v2::Id3v2Tag;
use crate::probe::ParseOptions; use crate::probe::ParseOptions;
use crate::properties::FileProperties; use crate::properties::FileProperties;
use crate::resolve::{register_custom_resolver, FileResolver}; use crate::resolve::{register_custom_resolver, FileResolver};
@ -148,7 +148,7 @@ mod tests {
#[lofty(file_type = "MyFile")] #[lofty(file_type = "MyFile")]
struct MyFile { struct MyFile {
#[lofty(tag_type = "Id3v2")] #[lofty(tag_type = "Id3v2")]
id3v2_tag: Option<ID3v2Tag>, id3v2_tag: Option<Id3v2Tag>,
properties: FileProperties, properties: FileProperties,
} }
@ -180,7 +180,7 @@ mod tests {
_reader: &mut R, _reader: &mut R,
_parse_options: ParseOptions, _parse_options: ParseOptions,
) -> crate::error::Result<Self> { ) -> crate::error::Result<Self> {
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.set_artist(String::from("All is well!")); tag.set_artist(String::from("All is well!"));
Ok(Self { Ok(Self {

View file

@ -85,14 +85,14 @@ macro_rules! impl_accessor {
/// Converting between formats /// Converting between formats
/// ///
/// ```rust /// ```rust
/// use lofty::id3::v2::ID3v2Tag; /// use lofty::id3::v2::Id3v2Tag;
/// use lofty::{Tag, TagType}; /// use lofty::{Tag, TagType};
/// ///
/// // Converting between formats is as simple as an `into` call. /// // Converting between formats is as simple as an `into` call.
/// // However, such conversions can potentially be *very* lossy. /// // 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(); /// let id3v2_tag: Id3v2Tag = tag.into();
/// ``` /// ```
#[derive(Clone)] #[derive(Clone)]
pub struct Tag { pub struct Tag {

View file

@ -172,10 +172,10 @@ fn flac_remove_id3v2() {
#[test] #[test]
fn flac_try_write_non_empty_id3v2() { fn flac_try_write_non_empty_id3v2() {
use lofty::id3::v2::ID3v2Tag; use lofty::id3::v2::Id3v2Tag;
use lofty::Accessor; use lofty::Accessor;
let mut tag = ID3v2Tag::default(); let mut tag = Id3v2Tag::default();
tag.set_artist(String::from("Foo artist")); tag.set_artist(String::from("Foo artist"));
assert!(tag assert!(tag

View file

@ -1,6 +1,6 @@
// Tests for special case conversions // Tests for special case conversions
use lofty::id3::v2::{CommentFrame, Frame, FrameFlags, ID3v2Tag, UnsynchronizedTextFrame}; use lofty::id3::v2::{CommentFrame, Frame, FrameFlags, Id3v2Tag, UnsynchronizedTextFrame};
use lofty::{ItemKey, Tag, TagType, TextEncoding}; use lofty::{ItemKey, Tag, TagType, TextEncoding};
#[test] #[test]
@ -9,7 +9,7 @@ fn tag_to_id3v2_lang_frame() {
tag.insert_text(ItemKey::Lyrics, String::from("Test lyrics")); tag.insert_text(ItemKey::Lyrics, String::from("Test lyrics"));
tag.insert_text(ItemKey::Comment, String::from("Test comment")); tag.insert_text(ItemKey::Comment, String::from("Test comment"));
let id3: ID3v2Tag = tag.into(); let id3: Id3v2Tag = tag.into();
assert_eq!( assert_eq!(
id3.get("USLT"), id3.get("USLT"),