ID3v2: Switch FrameID to UpperCamelCase

This commit is contained in:
Serial 2023-04-20 22:38:37 -04:00 committed by Alex
parent d7dffcf0d2
commit b5c71e8fde
8 changed files with 82 additions and 82 deletions

View file

@ -83,7 +83,7 @@ pub enum Id3v2ErrorKind {
// Frame
/// Arises when a frame ID contains invalid characters (must be within `'A'..'Z'` or `'0'..'9'`)
BadFrameID,
BadFrameId,
/// Arises when a frame doesn't have enough data
BadFrameLength,
/// Arises when reading/writing a compressed or encrypted frame with no data length indicator
@ -112,7 +112,7 @@ pub enum Id3v2ErrorKind {
// Writing
/// Arises when attempting to write an encrypted frame with an invalid encryption method symbol (must be <= 0x80)
InvalidEncryptionMethodSymbol(u8),
/// Arises when attempting to write an invalid Frame (Bad `FrameID`/`FrameValue` pairing)
/// Arises when attempting to write an invalid Frame (Bad `FrameId`/`FrameValue` pairing)
BadFrame(String, &'static str),
/// Arises when attempting to write a [`CommentFrame`](crate::id3::v2::CommentFrame) or [`UnsynchronizedTextFrame`](crate::id3::v2::UnsynchronizedTextFrame) with an invalid language
InvalidLanguage([u8; 3]),
@ -133,7 +133,7 @@ impl Display for Id3v2ErrorKind {
},
// Frame
Self::BadFrameID => write!(f, "Failed to parse a frame ID"),
Self::BadFrameId => write!(f, "Failed to parse a frame ID"),
Self::BadFrameLength => write!(
f,
"Frame isn't long enough to extract the necessary information"

View file

@ -2,14 +2,14 @@ use super::FrameFlags;
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
use crate::id3::v2::util::synchsafe::SynchsafeInteger;
use crate::id3::v2::util::upgrade::{upgrade_v2, upgrade_v3};
use crate::id3::v2::FrameID;
use crate::id3::v2::FrameId;
use std::borrow::Cow;
use std::io::Read;
pub(crate) fn parse_v2_header<R>(
reader: &mut R,
) -> Result<Option<(FrameID<'static>, u32, FrameFlags)>>
) -> Result<Option<(FrameId<'static>, u32, FrameFlags)>>
where
R: Read,
{
@ -25,10 +25,10 @@ where
}
let id_str = std::str::from_utf8(&frame_header[..3])
.map_err(|_| Id3v2Error::new(Id3v2ErrorKind::BadFrameID))?;
.map_err(|_| Id3v2Error::new(Id3v2ErrorKind::BadFrameId))?;
let id = upgrade_v2(id_str).map_or_else(|| Cow::Owned(id_str.to_owned()), Cow::Borrowed);
let frame_id = FrameID::new_cow(id)?;
let frame_id = FrameId::new_cow(id)?;
let size = u32::from_be_bytes([0, frame_header[3], frame_header[4], frame_header[5]]);
@ -39,7 +39,7 @@ where
pub(crate) fn parse_header<R>(
reader: &mut R,
synchsafe: bool,
) -> Result<Option<(FrameID<'static>, u32, FrameFlags)>>
) -> Result<Option<(FrameId<'static>, u32, FrameFlags)>>
where
R: Read,
{
@ -64,7 +64,7 @@ where
}
let id_str = std::str::from_utf8(&frame_header[..frame_id_end])
.map_err(|_| Id3v2Error::new(Id3v2ErrorKind::BadFrameID))?;
.map_err(|_| Id3v2Error::new(Id3v2ErrorKind::BadFrameId))?;
let mut size = u32::from_be_bytes([
frame_header[4],
@ -73,7 +73,7 @@ where
frame_header[7],
]);
// Now upgrade the FrameID
// Now upgrade the FrameId
let id = if invalid_v2_frame {
if let Some(id) = upgrade_v2(id_str) {
Cow::Borrowed(id)
@ -85,7 +85,7 @@ where
} else {
Cow::Owned(id_str.to_owned())
};
let frame_id = FrameID::new_cow(id)?;
let frame_id = FrameId::new_cow(id)?;
// unsynch the frame size if necessary
if synchsafe {

View file

@ -6,7 +6,7 @@ use crate::tag::TagType;
/// An `ID3v2` frame ID
#[derive(PartialEq, Clone, Debug, Eq, Hash)]
pub enum FrameID<'a> {
pub enum FrameId<'a> {
/// A valid `ID3v2.3/4` frame
Valid(Cow<'a, str>),
/// When an `ID3v2.2` key couldn't be upgraded
@ -17,8 +17,8 @@ pub enum FrameID<'a> {
Outdated(Cow<'a, str>),
}
impl<'a> FrameID<'a> {
/// Attempts to create a `FrameID` from an ID string
impl<'a> FrameId<'a> {
/// Attempts to create a `FrameId` from an ID string
///
/// # Errors
///
@ -36,23 +36,23 @@ impl<'a> FrameID<'a> {
Self::verify_id(&id)?;
match id.len() {
3 => Ok(FrameID::Outdated(id)),
4 => Ok(FrameID::Valid(id)),
_ => Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameID).into()),
3 => Ok(FrameId::Outdated(id)),
4 => Ok(FrameId::Valid(id)),
_ => Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameId).into()),
}
}
/// Extracts the string from the ID
pub fn as_str(&self) -> &str {
match self {
FrameID::Valid(v) | FrameID::Outdated(v) => v,
FrameId::Valid(v) | FrameId::Outdated(v) => v,
}
}
pub(super) fn verify_id(id_str: &str) -> Result<()> {
for c in id_str.chars() {
if !c.is_ascii_uppercase() && !c.is_ascii_digit() {
return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameID).into());
return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameId).into());
}
}
@ -68,15 +68,15 @@ impl<'a> FrameID<'a> {
}
/// Obtains an owned instance
pub fn into_owned(self) -> FrameID<'static> {
pub fn into_owned(self) -> FrameId<'static> {
match self {
Self::Valid(inner) => FrameID::Valid(Cow::Owned(inner.into_owned())),
Self::Outdated(inner) => FrameID::Outdated(Cow::Owned(inner.into_owned())),
Self::Valid(inner) => FrameId::Valid(Cow::Owned(inner.into_owned())),
Self::Outdated(inner) => FrameId::Outdated(Cow::Owned(inner.into_owned())),
}
}
}
impl<'a> TryFrom<&'a ItemKey> for FrameID<'a> {
impl<'a> TryFrom<&'a ItemKey> for FrameId<'a> {
type Error = LoftyError;
fn try_from(value: &'a ItemKey) -> std::prelude::rust_2015::Result<Self, Self::Error> {
@ -93,7 +93,7 @@ impl<'a> TryFrom<&'a ItemKey> for FrameID<'a> {
}
}
Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameID).into())
Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameId).into())
},
}
}

View file

@ -13,7 +13,7 @@ use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::tag::item::{ItemKey, ItemValue, TagItem};
use crate::tag::TagType;
use crate::util::text::TextEncoding;
use id::FrameID;
use id::FrameId;
use std::borrow::Cow;
use std::convert::{TryFrom, TryInto};
@ -48,16 +48,16 @@ pub(super) const UNKNOWN_LANGUAGE: [u8; 3] = *b"XXX";
/// ### ID3v2.2
///
/// `ID3v2.2` frame IDs are 3 characters. When reading these tags, [`upgrade_v2`] is used, which has a list of all of the common IDs
/// that have a mapping to `ID3v2.4`. Any ID that fails to be converted will be stored as [`FrameID::Outdated`], and it must be manually
/// that have a mapping to `ID3v2.4`. Any ID that fails to be converted will be stored as [`FrameId::Outdated`], and it must be manually
/// upgraded before it can be written. **Lofty** will not write `ID3v2.2` tags.
///
/// ### ID3v2.3
///
/// `ID3v2.3`, unlike `ID3v2.2`, stores frame IDs in 4 characters like `ID3v2.4`. There are some IDs that need upgrading (See [`upgrade_v3`]),
/// but anything that fails to be upgraded **will not** be stored as [`FrameID::Outdated`], as it is likely not an issue to write.
/// but anything that fails to be upgraded **will not** be stored as [`FrameId::Outdated`], as it is likely not an issue to write.
#[derive(Clone, Debug, Eq)]
pub struct Frame<'a> {
pub(super) id: FrameID<'a>,
pub(super) id: FrameId<'a>,
pub(super) value: FrameValue,
pub(super) flags: FrameFlags,
}
@ -112,15 +112,15 @@ impl<'a> Frame<'a> {
None => id,
Some(upgraded) => Cow::Borrowed(upgraded),
},
_ => return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameID).into()),
_ => return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameId).into()),
};
let id = FrameID::new_cow(id_upgraded)?;
let id = FrameId::new_cow(id_upgraded)?;
Ok(Self { id, value, flags })
}
/// Extract the string from the [`FrameID`]
/// Extract the string from the [`FrameId`]
pub fn id_str(&self) -> &str {
self.id.as_str()
}
@ -143,7 +143,7 @@ impl<'a> Frame<'a> {
// Used internally, has no correctness checks
pub(crate) fn text(id: Cow<'a, str>, content: String) -> Self {
Self {
id: FrameID::Valid(id),
id: FrameId::Valid(id),
value: FrameValue::Text(TextInformationFrame {
encoding: TextEncoding::UTF8,
value: content,
@ -179,7 +179,7 @@ pub enum FrameValue {
///
/// * This is used for rare frames, such as GEOB, SYLT, and ATXT to skip additional unnecessary work.
/// See [`GeneralEncapsulatedObject::parse`](crate::id3::v2::GeneralEncapsulatedObject::parse), [`SynchronizedText::parse`](crate::id3::v2::SynchronizedText::parse), and [`AudioTextFrame::parse`](crate::id3::v2::AudioTextFrame::parse) respectively
/// * This is used for **all** frames with an ID of [`FrameID::Outdated`]
/// * This is used for **all** frames with an ID of [`FrameId::Outdated`]
/// * This is used for unknown frames
Binary(Vec<u8>),
/// Unique file identifier
@ -326,10 +326,10 @@ impl From<TagItem> for Option<Frame<'static>> {
fn from(input: TagItem) -> Self {
let frame_id;
let value;
match input.key().try_into().map(FrameID::into_owned) {
match input.key().try_into().map(FrameId::into_owned) {
Ok(id) => {
value = match (&id, input.item_value) {
(FrameID::Valid(ref s), ItemValue::Text(text)) if s == "COMM" => {
(FrameId::Valid(ref s), ItemValue::Text(text)) if s == "COMM" => {
FrameValue::Comment(CommentFrame {
encoding: TextEncoding::UTF8,
language: UNKNOWN_LANGUAGE,
@ -337,7 +337,7 @@ impl From<TagItem> for Option<Frame<'static>> {
content: text,
})
},
(FrameID::Valid(ref s), ItemValue::Text(text)) if s == "USLT" => {
(FrameId::Valid(ref s), ItemValue::Text(text)) if s == "USLT" => {
FrameValue::UnsynchronizedText(UnsynchronizedTextFrame {
encoding: TextEncoding::UTF8,
language: UNKNOWN_LANGUAGE,
@ -345,7 +345,7 @@ impl From<TagItem> for Option<Frame<'static>> {
content: text,
})
},
(FrameID::Valid(ref s), ItemValue::Locator(text) | ItemValue::Text(text))
(FrameId::Valid(ref s), ItemValue::Locator(text) | ItemValue::Text(text))
if s == "WXXX" =>
{
FrameValue::UserUrl(ExtendedUrlFrame {
@ -354,14 +354,14 @@ impl From<TagItem> for Option<Frame<'static>> {
content: text,
})
},
(FrameID::Valid(ref s), ItemValue::Text(text)) if s == "TXXX" => {
(FrameId::Valid(ref s), ItemValue::Text(text)) if s == "TXXX" => {
FrameValue::UserText(ExtendedTextFrame {
encoding: TextEncoding::UTF8,
description: EMPTY_CONTENT_DESCRIPTOR,
content: text,
})
},
(FrameID::Valid(ref s), ItemValue::Binary(text)) if s == "POPM" => {
(FrameId::Valid(ref s), ItemValue::Binary(text)) if s == "POPM" => {
FrameValue::Popularimeter(Popularimeter::parse(&text).ok()?)
},
(_, item_value) => {
@ -378,7 +378,7 @@ impl From<TagItem> for Option<Frame<'static>> {
Err(_) => match input.item_key.map_key(TagType::Id3v2, true) {
Some(desc) => match input.item_value {
ItemValue::Text(text) => {
frame_id = FrameID::Valid(Cow::Borrowed("TXXX"));
frame_id = FrameId::Valid(Cow::Borrowed("TXXX"));
value = FrameValue::UserText(ExtendedTextFrame {
encoding: TextEncoding::UTF8,
description: String::from(desc),
@ -386,7 +386,7 @@ impl From<TagItem> for Option<Frame<'static>> {
})
},
ItemValue::Locator(locator) => {
frame_id = FrameID::Valid(Cow::Borrowed("WXXX"));
frame_id = FrameId::Valid(Cow::Borrowed("WXXX"));
value = FrameValue::UserUrl(ExtendedUrlFrame {
encoding: TextEncoding::UTF8,
description: String::from(desc),
@ -404,7 +404,7 @@ impl From<TagItem> for Option<Frame<'static>> {
owner: MUSICBRAINZ_UFID_OWNER.to_owned(),
identifier: recording_id.into_bytes(),
};
frame_id = FrameID::Valid(Cow::Borrowed("UFID"));
frame_id = FrameId::Valid(Cow::Borrowed("UFID"));
value = FrameValue::UniqueFileIdentifier(frame);
},
_ => {
@ -424,16 +424,16 @@ impl From<TagItem> for Option<Frame<'static>> {
#[derive(Clone)]
pub(crate) struct FrameRef<'a> {
pub id: FrameID<'a>,
pub id: FrameId<'a>,
pub value: Cow<'a, FrameValue>,
pub flags: FrameFlags,
}
impl<'a> Frame<'a> {
pub(crate) fn as_opt_ref(&'a self) -> Option<FrameRef<'a>> {
if let FrameID::Valid(id) = &self.id {
if let FrameId::Valid(id) = &self.id {
Some(FrameRef {
id: FrameID::Valid(Cow::Borrowed(id)),
id: FrameId::Valid(Cow::Borrowed(id)),
value: Cow::Borrowed(self.content()),
flags: self.flags,
})
@ -447,8 +447,8 @@ impl<'a> TryFrom<&'a TagItem> for FrameRef<'a> {
type Error = LoftyError;
fn try_from(tag_item: &'a TagItem) -> std::result::Result<Self, Self::Error> {
let id: Result<FrameID<'a>> = tag_item.key().try_into();
let frame_id: FrameID<'a>;
let id: Result<FrameId<'a>> = tag_item.key().try_into();
let frame_id: FrameId<'a>;
let value: FrameValue;
match id {
Ok(id) => {
@ -505,12 +505,12 @@ impl<'a> TryFrom<&'a TagItem> for FrameRef<'a> {
},
Err(_) => {
let Some(desc) = tag_item.key().map_key(TagType::Id3v2, true) else {
return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameID).into());
return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameId).into());
};
match tag_item.value() {
ItemValue::Text(text) => {
frame_id = FrameID::Valid(Cow::Borrowed("TXXX"));
frame_id = FrameId::Valid(Cow::Borrowed("TXXX"));
value = FrameValue::UserText(ExtendedTextFrame {
encoding: TextEncoding::UTF8,
description: String::from(desc),
@ -518,14 +518,14 @@ impl<'a> TryFrom<&'a TagItem> for FrameRef<'a> {
})
},
ItemValue::Locator(locator) => {
frame_id = FrameID::Valid(Cow::Borrowed("WXXX"));
frame_id = FrameId::Valid(Cow::Borrowed("WXXX"));
value = FrameValue::UserUrl(ExtendedUrlFrame {
encoding: TextEncoding::UTF8,
description: String::from(desc),
content: locator.clone(),
})
},
_ => return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameID).into()),
_ => return Err(Id3v2Error::new(Id3v2ErrorKind::BadFrameId).into()),
}
},
}

View file

@ -11,7 +11,7 @@ use byteorder::ReadBytesExt;
/// An extended `ID3v2` text frame
///
/// This is used in the `TXXX` frame, where the frames
/// are told apart by descriptions, rather than their [`FrameID`](crate::id3::v2::FrameID)s.
/// are told apart by descriptions, rather than their [`FrameID`](crate::id3::v2::FrameId)s.
/// This means for each `ExtendedTextFrame` in the tag, the description
/// must be unique.
#[derive(Clone, Debug, Eq)]

View file

@ -10,7 +10,7 @@ use byteorder::ReadBytesExt;
/// An extended `ID3v2` URL frame
///
/// This is used in the `WXXX` frame, where the frames
/// are told apart by descriptions, rather than their [`FrameID`](crate::id3::v2::FrameID)s.
/// are told apart by descriptions, rather than their [`FrameId`](crate::id3::v2::FrameId)s.
/// This means for each `ExtendedUrlFrame` in the tag, the description
/// must be unique.
#[derive(Clone, Debug, Eq)]

View file

@ -33,7 +33,7 @@ pub use tag::ID3v2Tag;
pub use items::*;
pub use frame::id::FrameID;
pub use frame::id::FrameId;
pub use frame::{Frame, FrameFlags, FrameValue};
pub use restrictions::{

View file

@ -1,5 +1,5 @@
use super::flags::ID3v2TagFlags;
use super::frame::id::FrameID;
use super::frame::id::FrameId;
use super::frame::{Frame, FrameFlags, FrameValue, EMPTY_CONTENT_DESCRIPTOR, UNKNOWN_LANGUAGE};
use super::ID3v2Version;
use crate::error::{LoftyError, Result};
@ -50,7 +50,7 @@ macro_rules! impl_accessor {
fn [<set_ $name>](&mut self, value: String) {
self.insert(new_text_frame(
FrameID::Valid(Cow::Borrowed($id).into()),
FrameId::Valid(Cow::Borrowed($id).into()),
value,
FrameFlags::default(),
));
@ -240,7 +240,7 @@ impl ID3v2Tag {
for (i, frame) in self.frames.iter().enumerate() {
match frame {
Frame {
id: FrameID::Valid(id),
id: FrameId::Valid(id),
value:
FrameValue::Picture(AttachedPictureFrame {
picture: Picture { pic_type, .. },
@ -270,7 +270,7 @@ impl ID3v2Tag {
pub fn remove_picture_type(&mut self, picture_type: PictureType) {
self.frames.retain(|f| {
!matches!(f, Frame {
id: FrameID::Valid(id),
id: FrameId::Valid(id),
value: FrameValue::Picture(AttachedPictureFrame {
picture: Picture {
pic_type: p_ty,
@ -286,7 +286,7 @@ impl ID3v2Tag {
pub fn unsync_text(&self) -> impl Iterator<Item = &UnsynchronizedTextFrame> + Clone {
self.frames.iter().filter_map(|f| match f {
Frame {
id: FrameID::Valid(id),
id: FrameId::Valid(id),
value: FrameValue::UnsynchronizedText(val),
..
} if id == "USLT" => Some(val),
@ -387,7 +387,7 @@ fn filter_comment_frame_by_description_mut<'a>(
}
}
fn new_text_frame(id: FrameID<'_>, value: String, flags: FrameFlags) -> Frame<'_> {
fn new_text_frame(id: FrameId<'_>, value: String, flags: FrameFlags) -> Frame<'_> {
Frame {
id,
value: FrameValue::Text(TextInformationFrame {
@ -400,7 +400,7 @@ fn new_text_frame(id: FrameID<'_>, value: String, flags: FrameFlags) -> Frame<'_
fn new_comment_frame(content: String, flags: FrameFlags) -> Frame<'static> {
Frame {
id: FrameID::Valid(Cow::Borrowed(COMMENT_FRAME_ID)),
id: FrameId::Valid(Cow::Borrowed(COMMENT_FRAME_ID)),
value: FrameValue::Comment(CommentFrame {
encoding: TextEncoding::UTF8,
language: UNKNOWN_LANGUAGE,
@ -413,7 +413,7 @@ fn new_comment_frame(content: String, flags: FrameFlags) -> Frame<'static> {
fn new_picture_frame(picture: Picture, flags: FrameFlags) -> Frame<'static> {
Frame {
id: FrameID::Valid(Cow::Borrowed("APIC")),
id: FrameId::Valid(Cow::Borrowed("APIC")),
value: FrameValue::Picture(AttachedPictureFrame {
encoding: TextEncoding::UTF8,
picture,
@ -560,7 +560,7 @@ impl Accessor for ID3v2Tag {
impl TagExt for ID3v2Tag {
type Err = LoftyError;
type RefKey<'a> = &'a FrameID<'a>;
type RefKey<'a> = &'a FrameId<'a>;
fn len(&self) -> usize {
self.frames.len()
@ -580,7 +580,7 @@ impl TagExt for ID3v2Tag {
///
/// * Attempting to write the tag to a format that does not support it
/// * Attempting to write an encrypted frame without a valid method symbol or data length indicator
/// * Attempting to write an invalid [`FrameID`]/[`FrameValue`] pairing
/// * Attempting to write an invalid [`FrameId`]/[`FrameValue`] pairing
fn save_to(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
Id3v2TagRef {
flags: self.flags,
@ -925,7 +925,7 @@ impl MergeTag for SplitTagRemainder {
.expect("valid frame id");
if let Some(text) = join_text_items(&mut tag, [item_key].into_iter()) {
let frame = new_text_frame(
FrameID::Valid(Cow::Borrowed(frame_id)),
FrameId::Valid(Cow::Borrowed(frame_id)),
text,
FrameFlags::default(),
);
@ -946,7 +946,7 @@ impl MergeTag for SplitTagRemainder {
);
if let Some(text) = join_text_items(&mut tag, &[ItemKey::Label, ItemKey::Publisher]) {
let frame = new_text_frame(
FrameID::Valid(Cow::Borrowed(frame_id)),
FrameId::Valid(Cow::Borrowed(frame_id)),
text,
FrameFlags::default(),
);
@ -1042,7 +1042,7 @@ pub(crate) fn tag_frames(tag: &Tag) -> impl Iterator<Item = FrameRef<'_>> + Clon
));
let pictures = tag.pictures().iter().map(|p| FrameRef {
id: FrameID::Valid(Cow::Borrowed("APIC")),
id: FrameId::Valid(Cow::Borrowed("APIC")),
value: Cow::Owned(FrameValue::Picture(AttachedPictureFrame {
encoding: TextEncoding::UTF8,
picture: p.clone(),
@ -1077,7 +1077,7 @@ mod tests {
};
use crate::id3::v2::{
read_id3v2_header, AttachedPictureFrame, CommentFrame, ExtendedTextFrame, Frame,
FrameFlags, FrameID, FrameValue, ID3v2Tag, ID3v2Version, TextInformationFrame,
FrameFlags, FrameId, FrameValue, ID3v2Tag, ID3v2Version, TextInformationFrame,
UrlLinkFrame,
};
use crate::tag::utils::test_utils::read_path;
@ -1259,7 +1259,7 @@ mod tests {
assert_eq!(converted_tag.frames.len(), 1);
let actual_frame = converted_tag.frames.first().unwrap();
assert_eq!(actual_frame.id, FrameID::Valid(Cow::Borrowed("POPM")));
assert_eq!(actual_frame.id, FrameId::Valid(Cow::Borrowed("POPM")));
// Note: as POPM frames are considered equal by email alone, each field must
// be separately validated
match actual_frame.content() {
@ -1276,7 +1276,7 @@ mod tests {
fn fail_write_bad_frame() {
let mut tag = ID3v2Tag::default();
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("ABCD")),
id: FrameId::Valid(Cow::Borrowed("ABCD")),
value: FrameValue::Url(UrlLinkFrame(String::from("FOO URL"))),
flags: FrameFlags::default(),
});
@ -1342,7 +1342,7 @@ mod tests {
let flags = FrameFlags::default();
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("TIT2")),
id: FrameId::Valid(Cow::Borrowed("TIT2")),
value: FrameValue::Text(TextInformationFrame {
encoding,
value: String::from("TempleOS Hymn Risen (Remix)"),
@ -1351,7 +1351,7 @@ mod tests {
});
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("TPE1")),
id: FrameId::Valid(Cow::Borrowed("TPE1")),
value: FrameValue::Text(TextInformationFrame {
encoding,
value: String::from("Dave Eddy"),
@ -1360,7 +1360,7 @@ mod tests {
});
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("TRCK")),
id: FrameId::Valid(Cow::Borrowed("TRCK")),
value: FrameValue::Text(TextInformationFrame {
encoding: TextEncoding::Latin1,
value: String::from("1"),
@ -1369,7 +1369,7 @@ mod tests {
});
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("TALB")),
id: FrameId::Valid(Cow::Borrowed("TALB")),
value: FrameValue::Text(TextInformationFrame {
encoding,
value: String::from("Summer"),
@ -1378,7 +1378,7 @@ mod tests {
});
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("TDRC")),
id: FrameId::Valid(Cow::Borrowed("TDRC")),
value: FrameValue::Text(TextInformationFrame {
encoding,
value: String::from("2017"),
@ -1387,7 +1387,7 @@ mod tests {
});
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("TCON")),
id: FrameId::Valid(Cow::Borrowed("TCON")),
value: FrameValue::Text(TextInformationFrame {
encoding,
value: String::from("Electronic"),
@ -1396,7 +1396,7 @@ mod tests {
});
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("TLEN")),
id: FrameId::Valid(Cow::Borrowed("TLEN")),
value: FrameValue::Text(TextInformationFrame {
encoding: TextEncoding::UTF16,
value: String::from("213017"),
@ -1405,7 +1405,7 @@ mod tests {
});
tag.insert(Frame {
id: FrameID::Valid(Cow::Borrowed("APIC")),
id: FrameId::Valid(Cow::Borrowed("APIC")),
value: FrameValue::Picture(AttachedPictureFrame {
encoding: TextEncoding::Latin1,
picture: Picture {
@ -1487,7 +1487,7 @@ mod tests {
assert_eq!(
tag.frames.first(),
Some(&Frame {
id: FrameID::Valid(Cow::Borrowed("APIC")),
id: FrameId::Valid(Cow::Borrowed("APIC")),
value: FrameValue::Picture(AttachedPictureFrame {
encoding: TextEncoding::UTF8,
picture
@ -1504,7 +1504,7 @@ mod tests {
assert_eq!(parsed_tag.frames.len(), 1);
let popm_frame = parsed_tag.frames.first().unwrap();
assert_eq!(popm_frame.id, FrameID::Valid(Cow::Borrowed("POPM")));
assert_eq!(popm_frame.id, FrameId::Valid(Cow::Borrowed("POPM")));
assert_eq!(
popm_frame.value,
FrameValue::Popularimeter(Popularimeter {
@ -1775,7 +1775,7 @@ mod tests {
assert_eq!(
id3v2.frames.first(),
Some(&Frame {
id: FrameID::Valid(Cow::Borrowed("TXXX")),
id: FrameId::Valid(Cow::Borrowed("TXXX")),
value: FrameValue::UserText(ExtendedTextFrame {
description: String::from("FOO_BAR"),
encoding: TextEncoding::UTF8, // Not considered by PartialEq!
@ -2022,7 +2022,7 @@ mod tests {
fn create_tag_with_trck_and_tpos_frame(content: &'static str) -> Tag {
fn insert_frame(id: &'static str, content: &'static str, tag: &mut ID3v2Tag) {
tag.insert(new_text_frame(
FrameID::Valid(Cow::Borrowed(id)),
FrameId::Valid(Cow::Borrowed(id)),
content.to_string(),
FrameFlags::default(),
));