mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 14:44:22 +00:00
ID3v2: Convert remaining types to UpperCamelCase
This commit is contained in:
parent
cb01e82d07
commit
8d696e8704
17 changed files with 84 additions and 84 deletions
|
@ -94,7 +94,7 @@ pub enum Id3v2ErrorKind {
|
|||
InvalidUnsynchronisation,
|
||||
/// Arises when a text encoding other than Latin-1 or UTF-16 appear in an ID3v2.2 tag
|
||||
V2InvalidTextEncoding,
|
||||
/// Arises when an invalid picture format is parsed. Only applicable to [`ID3v2Version::V2`](crate::id3::v2::ID3v2Version::V2)
|
||||
/// Arises when an invalid picture format is parsed. Only applicable to [`ID3v2Version::V2`](crate::id3::v2::Id3v2Version::V2)
|
||||
BadPictureFormat(String),
|
||||
/// Arises when invalid data is encountered while reading an ID3v2 synchronized text frame
|
||||
BadSyncText,
|
||||
|
|
|
@ -8,7 +8,7 @@ pub mod v2;
|
|||
|
||||
use crate::error::{ErrorKind, LoftyError, Result};
|
||||
use crate::macros::try_vec;
|
||||
use v2::{read_id3v2_header, ID3v2Header};
|
||||
use v2::{read_id3v2_header, Id3v2Header};
|
||||
|
||||
use std::io::{Read, Seek, SeekFrom};
|
||||
use std::ops::Neg;
|
||||
|
@ -85,7 +85,7 @@ where
|
|||
pub(crate) fn find_id3v2<R>(
|
||||
data: &mut R,
|
||||
read: bool,
|
||||
) -> Result<ID3FindResults<ID3v2Header, Option<Vec<u8>>>>
|
||||
) -> Result<ID3FindResults<Id3v2Header, Option<Vec<u8>>>>
|
||||
where
|
||||
R: Read + Seek,
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ use super::restrictions::TagRestrictions;
|
|||
/// Flags that apply to the entire tag
|
||||
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
pub struct ID3v2TagFlags {
|
||||
pub struct Id3v2TagFlags {
|
||||
/// Whether or not all frames are unsynchronised. See [`FrameFlags::unsynchronisation`](crate::id3::v2::FrameFlags::unsynchronisation)
|
||||
pub unsynchronisation: bool,
|
||||
/// Indicates if the tag is in an experimental stage
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::id3::v2::items::{
|
|||
AttachedPictureFrame, CommentFrame, ExtendedTextFrame, ExtendedUrlFrame, Popularimeter,
|
||||
TextInformationFrame, UniqueFileIdentifierFrame, UnsynchronizedTextFrame, UrlLinkFrame,
|
||||
};
|
||||
use crate::id3::v2::ID3v2Version;
|
||||
use crate::id3::v2::Id3v2Version;
|
||||
use crate::macros::err;
|
||||
use crate::util::text::TextEncoding;
|
||||
|
||||
|
@ -12,9 +12,9 @@ use std::io::Read;
|
|||
|
||||
#[rustfmt::skip]
|
||||
pub(super) fn parse_content<R: Read>(
|
||||
reader: &mut R,
|
||||
id: &str,
|
||||
version: ID3v2Version,
|
||||
reader: &mut R,
|
||||
id: &str,
|
||||
version: Id3v2Version,
|
||||
) -> Result<Option<FrameValue>> {
|
||||
Ok(match id {
|
||||
// The ID was previously upgraded, but the content remains unchanged, so version is necessary
|
||||
|
@ -45,9 +45,9 @@ pub(super) fn parse_content<R: Read>(
|
|||
|
||||
pub(in crate::id3::v2) fn verify_encoding(
|
||||
encoding: u8,
|
||||
version: ID3v2Version,
|
||||
version: Id3v2Version,
|
||||
) -> Result<TextEncoding> {
|
||||
if version == ID3v2Version::V2 && (encoding != 0 && encoding != 1) {
|
||||
if version == Id3v2Version::V2 && (encoding != 0 && encoding != 1) {
|
||||
return Err(Id3v2Error::new(Id3v2ErrorKind::V2InvalidTextEncoding).into());
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use super::items::{
|
|||
TextInformationFrame, UniqueFileIdentifierFrame, UnsynchronizedTextFrame, UrlLinkFrame,
|
||||
};
|
||||
use super::util::upgrade::{upgrade_v2, upgrade_v3};
|
||||
use super::ID3v2Version;
|
||||
use super::Id3v2Version;
|
||||
use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
|
||||
use crate::tag::item::{ItemKey, ItemValue, TagItem};
|
||||
use crate::tag::TagType;
|
||||
|
@ -272,7 +272,7 @@ impl FrameValue {
|
|||
FrameValue::UserText(content) => content.as_bytes(),
|
||||
FrameValue::UserUrl(content) => content.as_bytes(),
|
||||
FrameValue::Url(link) => link.as_bytes(),
|
||||
FrameValue::Picture(attached_picture) => attached_picture.as_bytes(ID3v2Version::V4)?,
|
||||
FrameValue::Picture(attached_picture) => attached_picture.as_bytes(Id3v2Version::V4)?,
|
||||
FrameValue::Popularimeter(popularimeter) => popularimeter.as_bytes(),
|
||||
FrameValue::Binary(binary) => binary.clone(),
|
||||
FrameValue::UniqueFileIdentifier(frame) => frame.as_bytes(),
|
||||
|
|
|
@ -3,7 +3,7 @@ use super::Frame;
|
|||
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
|
||||
use crate::id3::v2::frame::content::parse_content;
|
||||
use crate::id3::v2::util::synchsafe::{SynchsafeInteger, UnsynchronizedStream};
|
||||
use crate::id3::v2::{FrameFlags, FrameId, FrameValue, ID3v2Version};
|
||||
use crate::id3::v2::{FrameFlags, FrameId, FrameValue, Id3v2Version};
|
||||
use crate::macros::try_vec;
|
||||
|
||||
use std::io::Read;
|
||||
|
@ -11,15 +11,15 @@ use std::io::Read;
|
|||
use byteorder::{BigEndian, ReadBytesExt};
|
||||
|
||||
impl<'a> Frame<'a> {
|
||||
pub(crate) fn read<R>(reader: &mut R, version: ID3v2Version) -> Result<(Option<Self>, bool)>
|
||||
pub(crate) fn read<R>(reader: &mut R, version: Id3v2Version) -> Result<(Option<Self>, bool)>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
// The header will be upgraded to ID3v2.4 past this point, so they can all be treated the same
|
||||
let (id, mut size, mut flags) = match match version {
|
||||
ID3v2Version::V2 => parse_v2_header(reader)?,
|
||||
ID3v2Version::V3 => parse_header(reader, false)?,
|
||||
ID3v2Version::V4 => parse_header(reader, true)?,
|
||||
Id3v2Version::V2 => parse_v2_header(reader)?,
|
||||
Id3v2Version::V3 => parse_header(reader, false)?,
|
||||
Id3v2Version::V4 => parse_header(reader, true)?,
|
||||
} {
|
||||
None => return Ok((None, true)),
|
||||
Some(frame_header) => frame_header,
|
||||
|
@ -170,7 +170,7 @@ fn parse_frame<R: Read>(
|
|||
reader: &mut R,
|
||||
id: FrameId<'static>,
|
||||
flags: FrameFlags,
|
||||
version: ID3v2Version,
|
||||
version: Id3v2Version,
|
||||
) -> Result<(Option<Frame<'static>>, bool)> {
|
||||
match parse_content(reader, id.as_str(), version)? {
|
||||
Some(value) => Ok((Some(Frame { id, value, flags }), false)),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
|
||||
use crate::id3::v2::ID3v2Version;
|
||||
use crate::id3::v2::Id3v2Version;
|
||||
use crate::macros::err;
|
||||
use crate::picture::{MimeType, Picture, PictureType};
|
||||
use crate::util::text::{encode_text, TextEncoding};
|
||||
|
@ -33,7 +33,7 @@ impl AttachedPictureFrame {
|
|||
/// ID3v2.2:
|
||||
///
|
||||
/// * The format is not "PNG" or "JPG"
|
||||
pub fn parse<R>(reader: &mut R, version: ID3v2Version) -> Result<Self>
|
||||
pub fn parse<R>(reader: &mut R, version: Id3v2Version) -> Result<Self>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ impl AttachedPictureFrame {
|
|||
None => err!(NotAPicture),
|
||||
};
|
||||
|
||||
let mime_type = if version == ID3v2Version::V2 {
|
||||
let mime_type = if version == Id3v2Version::V2 {
|
||||
let mut format = [0; 3];
|
||||
reader.read_exact(&mut format)?;
|
||||
|
||||
|
@ -91,16 +91,16 @@ impl AttachedPictureFrame {
|
|||
/// ID3v2.2:
|
||||
///
|
||||
/// * The mimetype is not [`MimeType::Png`] or [`MimeType::Jpeg`]
|
||||
pub fn as_bytes(&self, version: ID3v2Version) -> Result<Vec<u8>> {
|
||||
pub fn as_bytes(&self, version: Id3v2Version) -> Result<Vec<u8>> {
|
||||
let mut data = vec![self.encoding as u8];
|
||||
|
||||
let max_size = match version {
|
||||
// ID3v2.2 uses a 24-bit number for sizes
|
||||
ID3v2Version::V2 => 0xFFFF_FF16_u64,
|
||||
Id3v2Version::V2 => 0xFFFF_FF16_u64,
|
||||
_ => u64::from(u32::MAX),
|
||||
};
|
||||
|
||||
if version == ID3v2Version::V2 {
|
||||
if version == Id3v2Version::V2 {
|
||||
// ID3v2.2 PIC is pretty limited with formats
|
||||
let format = match self.picture.mime_type {
|
||||
MimeType::Png => "PNG",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::error::{Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
|
||||
use crate::id3::v2::frame::content::verify_encoding;
|
||||
use crate::id3::v2::ID3v2Version;
|
||||
use crate::id3::v2::Id3v2Version;
|
||||
use crate::util::text::{decode_text, encode_text, read_to_terminator, utf16_decode, TextEncoding};
|
||||
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
@ -48,7 +48,7 @@ impl ExtendedTextFrame {
|
|||
/// ID3v2.2:
|
||||
///
|
||||
/// * The encoding is not [`TextEncoding::Latin1`] or [`TextEncoding::UTF16`]
|
||||
pub fn parse<R>(reader: &mut R, version: ID3v2Version) -> Result<Option<Self>>
|
||||
pub fn parse<R>(reader: &mut R, version: Id3v2Version) -> Result<Option<Self>>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::error::Result;
|
||||
use crate::id3::v2::frame::content::verify_encoding;
|
||||
use crate::id3::v2::ID3v2Version;
|
||||
use crate::id3::v2::Id3v2Version;
|
||||
use crate::util::text::{decode_text, encode_text, TextEncoding};
|
||||
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
@ -48,7 +48,7 @@ impl ExtendedUrlFrame {
|
|||
/// ID3v2.2:
|
||||
///
|
||||
/// * The encoding is not [`TextEncoding::Latin1`] or [`TextEncoding::UTF16`]
|
||||
pub fn parse<R>(reader: &mut R, version: ID3v2Version) -> Result<Option<Self>>
|
||||
pub fn parse<R>(reader: &mut R, version: Id3v2Version) -> Result<Option<Self>>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
|
||||
use crate::id3::v2::frame::content::verify_encoding;
|
||||
use crate::id3::v2::ID3v2Version;
|
||||
use crate::id3::v2::Id3v2Version;
|
||||
use crate::util::text::{decode_text, encode_text, TextEncoding};
|
||||
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
@ -19,7 +19,7 @@ struct LanguageFrame {
|
|||
}
|
||||
|
||||
impl LanguageFrame {
|
||||
fn parse<R>(reader: &mut R, version: ID3v2Version) -> Result<Option<Self>>
|
||||
fn parse<R>(reader: &mut R, version: Id3v2Version) -> Result<Option<Self>>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ impl CommentFrame {
|
|||
/// ID3v2.2:
|
||||
///
|
||||
/// * The encoding is not [`TextEncoding::Latin1`] or [`TextEncoding::UTF16`]
|
||||
pub fn parse<R>(reader: &mut R, version: ID3v2Version) -> Result<Option<Self>>
|
||||
pub fn parse<R>(reader: &mut R, version: Id3v2Version) -> Result<Option<Self>>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ impl UnsynchronizedTextFrame {
|
|||
/// ID3v2.2:
|
||||
///
|
||||
/// * The encoding is not [`TextEncoding::Latin1`] or [`TextEncoding::UTF16`]
|
||||
pub fn parse<R>(reader: &mut R, version: ID3v2Version) -> Result<Option<Self>>
|
||||
pub fn parse<R>(reader: &mut R, version: Id3v2Version) -> Result<Option<Self>>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::error::Result;
|
||||
use crate::id3::v2::frame::content::verify_encoding;
|
||||
use crate::id3::v2::ID3v2Version;
|
||||
use crate::id3::v2::Id3v2Version;
|
||||
use crate::util::text::{decode_text, encode_text, TextEncoding};
|
||||
|
||||
use byteorder::ReadBytesExt;
|
||||
|
@ -28,7 +28,7 @@ impl TextInformationFrame {
|
|||
/// ID3v2.2:
|
||||
///
|
||||
/// * The encoding is not [`TextEncoding::Latin1`] or [`TextEncoding::UTF16`]
|
||||
pub fn parse<R>(reader: &mut R, version: ID3v2Version) -> Result<Option<Self>>
|
||||
pub fn parse<R>(reader: &mut R, version: Id3v2Version) -> Result<Option<Self>>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ use byteorder::{BigEndian, ByteOrder, ReadBytesExt};
|
|||
|
||||
// Exports
|
||||
|
||||
pub use flags::ID3v2TagFlags;
|
||||
pub use flags::Id3v2TagFlags;
|
||||
pub use util::upgrade::{upgrade_v2, upgrade_v3};
|
||||
|
||||
pub use tag::Id3v2Tag;
|
||||
|
@ -42,7 +42,7 @@ pub use restrictions::{
|
|||
|
||||
/// The ID3v2 version
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
||||
pub enum ID3v2Version {
|
||||
pub enum Id3v2Version {
|
||||
/// ID3v2.2
|
||||
V2,
|
||||
/// ID3v2.3
|
||||
|
@ -52,14 +52,14 @@ pub enum ID3v2Version {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub(crate) struct ID3v2Header {
|
||||
pub version: ID3v2Version,
|
||||
pub flags: ID3v2TagFlags,
|
||||
pub(crate) struct Id3v2Header {
|
||||
pub version: Id3v2Version,
|
||||
pub flags: Id3v2TagFlags,
|
||||
pub size: u32,
|
||||
pub extended_size: u32,
|
||||
}
|
||||
|
||||
pub(crate) fn read_id3v2_header<R>(bytes: &mut R) -> Result<ID3v2Header>
|
||||
pub(crate) fn read_id3v2_header<R>(bytes: &mut R) -> Result<Id3v2Header>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
|
@ -72,9 +72,9 @@ where
|
|||
|
||||
// Version is stored as [major, minor], but here we don't care about minor revisions unless there's an error.
|
||||
let version = match header[3] {
|
||||
2 => ID3v2Version::V2,
|
||||
3 => ID3v2Version::V3,
|
||||
4 => ID3v2Version::V4,
|
||||
2 => Id3v2Version::V2,
|
||||
3 => Id3v2Version::V3,
|
||||
4 => Id3v2Version::V4,
|
||||
major => {
|
||||
return Err(Id3v2Error::new(Id3v2ErrorKind::BadId3v2Version(major, header[4])).into())
|
||||
},
|
||||
|
@ -85,15 +85,15 @@ where
|
|||
// Compression was a flag only used in ID3v2.2 (bit 2).
|
||||
// At the time the ID3v2.2 specification was written, a compression scheme wasn't decided.
|
||||
// The spec recommends just ignoring the tag in this case.
|
||||
if version == ID3v2Version::V2 && flags & 0x40 == 0x40 {
|
||||
if version == Id3v2Version::V2 && flags & 0x40 == 0x40 {
|
||||
return Err(Id3v2Error::new(Id3v2ErrorKind::V2Compression).into());
|
||||
}
|
||||
|
||||
let mut flags_parsed = ID3v2TagFlags {
|
||||
let mut flags_parsed = Id3v2TagFlags {
|
||||
unsynchronisation: flags & 0x80 == 0x80,
|
||||
experimental: (version == ID3v2Version::V4 || version == ID3v2Version::V3)
|
||||
experimental: (version == Id3v2Version::V4 || version == Id3v2Version::V3)
|
||||
&& flags & 0x20 == 0x20,
|
||||
footer: (version == ID3v2Version::V4 || version == ID3v2Version::V3)
|
||||
footer: (version == Id3v2Version::V4 || version == Id3v2Version::V3)
|
||||
&& flags & 0x10 == 0x10,
|
||||
crc: false, // Retrieved later if applicable
|
||||
restrictions: None, // Retrieved later if applicable
|
||||
|
@ -103,7 +103,7 @@ where
|
|||
let mut extended_size = 0;
|
||||
|
||||
let extended_header =
|
||||
(version == ID3v2Version::V4 || version == ID3v2Version::V3) && flags & 0x40 == 0x40;
|
||||
(version == Id3v2Version::V4 || version == Id3v2Version::V3) && flags & 0x40 == 0x40;
|
||||
|
||||
if extended_header {
|
||||
extended_size = bytes.read_u32::<BigEndian>()?.unsynch();
|
||||
|
@ -139,7 +139,7 @@ where
|
|||
return Err(Id3v2Error::new(Id3v2ErrorKind::BadExtendedHeaderSize).into());
|
||||
}
|
||||
|
||||
Ok(ID3v2Header {
|
||||
Ok(Id3v2Header {
|
||||
version,
|
||||
flags: flags_parsed,
|
||||
size,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use super::frame::Frame;
|
||||
use super::tag::Id3v2Tag;
|
||||
use super::ID3v2Header;
|
||||
use super::Id3v2Header;
|
||||
use crate::error::Result;
|
||||
use crate::id3::v2::util::synchsafe::UnsynchronizedStream;
|
||||
|
||||
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
|
||||
R: Read,
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ where
|
|||
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
|
||||
R: Read,
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::flags::ID3v2TagFlags;
|
||||
use super::flags::Id3v2TagFlags;
|
||||
use super::frame::id::FrameId;
|
||||
use super::frame::{Frame, FrameFlags, FrameValue, EMPTY_CONTENT_DESCRIPTOR, UNKNOWN_LANGUAGE};
|
||||
use super::ID3v2Version;
|
||||
use super::Id3v2Version;
|
||||
use crate::error::{LoftyError, Result};
|
||||
use crate::id3::v2::frame::{FrameRef, MUSICBRAINZ_UFID_OWNER};
|
||||
use crate::id3::v2::items::{
|
||||
|
@ -99,8 +99,8 @@ macro_rules! impl_accessor {
|
|||
supported_formats(Aac, Aiff, Mpeg, Wav, read_only(Flac, Ape))
|
||||
)]
|
||||
pub struct Id3v2Tag {
|
||||
flags: ID3v2TagFlags,
|
||||
pub(super) original_version: ID3v2Version,
|
||||
flags: Id3v2TagFlags,
|
||||
pub(super) original_version: Id3v2Version,
|
||||
pub(crate) frames: Vec<Frame<'static>>,
|
||||
}
|
||||
|
||||
|
@ -125,8 +125,8 @@ impl<'a> IntoIterator for &'a Id3v2Tag {
|
|||
impl Default for Id3v2Tag {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
flags: ID3v2TagFlags::default(),
|
||||
original_version: ID3v2Version::V4,
|
||||
flags: Id3v2TagFlags::default(),
|
||||
original_version: Id3v2Version::V4,
|
||||
frames: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
@ -148,13 +148,13 @@ impl Id3v2Tag {
|
|||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns the [`ID3v2TagFlags`]
|
||||
pub fn flags(&self) -> &ID3v2TagFlags {
|
||||
/// Returns the [`Id3v2TagFlags`]
|
||||
pub fn flags(&self) -> &Id3v2TagFlags {
|
||||
&self.flags
|
||||
}
|
||||
|
||||
/// Restrict the tag's flags
|
||||
pub fn set_flags(&mut self, flags: ID3v2TagFlags) {
|
||||
pub fn set_flags(&mut self, flags: Id3v2TagFlags) {
|
||||
self.flags = flags
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ impl Id3v2Tag {
|
|||
///
|
||||
/// This is here, since the tag is upgraded to `ID3v2.4`, but a `v2.2` or `v2.3`
|
||||
/// tag may have been read.
|
||||
pub fn original_version(&self) -> ID3v2Version {
|
||||
pub fn original_version(&self) -> Id3v2Version {
|
||||
self.original_version
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ impl Id3v2Tag {
|
|||
|
||||
/// Gets the text for a frame
|
||||
///
|
||||
/// If the tag is [`ID3v2Version::V4`], this will allocate if the text contains any
|
||||
/// If the tag is [`Id3v2Version::V4`], this will allocate if the text contains any
|
||||
/// null (`'\0'`) text separators to replace them with a slash (`'/'`).
|
||||
pub fn get_text(&self, id: &str) -> Option<Cow<'_, str>> {
|
||||
let frame = self.get(id);
|
||||
|
@ -189,7 +189,7 @@ impl Id3v2Tag {
|
|||
}) = frame
|
||||
{
|
||||
if !value.contains(V4_MULTI_VALUE_SEPARATOR)
|
||||
|| self.original_version != ID3v2Version::V4
|
||||
|| self.original_version != Id3v2Version::V4
|
||||
{
|
||||
return Some(Cow::Borrowed(value.as_str()));
|
||||
}
|
||||
|
@ -994,14 +994,14 @@ impl From<Tag> for Id3v2Tag {
|
|||
}
|
||||
|
||||
pub(crate) struct Id3v2TagRef<'a, I: Iterator<Item = FrameRef<'a>> + 'a> {
|
||||
pub(crate) flags: ID3v2TagFlags,
|
||||
pub(crate) flags: Id3v2TagFlags,
|
||||
pub(crate) frames: I,
|
||||
}
|
||||
|
||||
impl<'a> Id3v2TagRef<'a, std::iter::Empty<FrameRef<'a>>> {
|
||||
pub(crate) fn empty() -> Self {
|
||||
Self {
|
||||
flags: ID3v2TagFlags::default(),
|
||||
flags: Id3v2TagFlags::default(),
|
||||
frames: std::iter::empty(),
|
||||
}
|
||||
}
|
||||
|
@ -1077,7 +1077,7 @@ mod tests {
|
|||
};
|
||||
use crate::id3::v2::{
|
||||
read_id3v2_header, AttachedPictureFrame, CommentFrame, ExtendedTextFrame, Frame,
|
||||
FrameFlags, FrameId, FrameValue, ID3v2Version, Id3v2Tag, TextInformationFrame,
|
||||
FrameFlags, FrameId, FrameValue, Id3v2Tag, Id3v2Version, TextInformationFrame,
|
||||
UrlLinkFrame,
|
||||
};
|
||||
use crate::tag::utils::test_utils::read_path;
|
||||
|
@ -1334,7 +1334,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[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();
|
||||
tag.original_version = version;
|
||||
|
||||
|
@ -1423,7 +1423,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn id3v24_full() {
|
||||
let tag = create_full_test_tag(ID3v2Version::V4);
|
||||
let tag = create_full_test_tag(Id3v2Version::V4);
|
||||
let parsed_tag = read_tag("tests/tags/assets/id3v2/test_full.id3v24");
|
||||
|
||||
assert_eq!(tag, parsed_tag);
|
||||
|
@ -1431,7 +1431,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn id3v23_full() {
|
||||
let tag = create_full_test_tag(ID3v2Version::V3);
|
||||
let tag = create_full_test_tag(Id3v2Version::V3);
|
||||
let parsed_tag = read_tag("tests/tags/assets/id3v2/test_full.id3v23");
|
||||
|
||||
assert_eq!(tag, parsed_tag);
|
||||
|
@ -1439,7 +1439,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn id3v22_full() {
|
||||
let tag = create_full_test_tag(ID3v2Version::V2);
|
||||
let tag = create_full_test_tag(Id3v2Version::V2);
|
||||
let parsed_tag = read_tag("tests/tags/assets/id3v2/test_full.id3v22");
|
||||
|
||||
assert_eq!(tag, parsed_tag);
|
||||
|
@ -1447,7 +1447,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn id3v24_footer() {
|
||||
let mut tag = create_full_test_tag(ID3v2Version::V4);
|
||||
let mut tag = create_full_test_tag(Id3v2Version::V4);
|
||||
tag.flags.footer = true;
|
||||
|
||||
let mut writer = Vec::new();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mod chunk_file;
|
||||
mod frame;
|
||||
|
||||
use super::ID3v2TagFlags;
|
||||
use super::Id3v2TagFlags;
|
||||
use crate::error::Result;
|
||||
use crate::file::FileType;
|
||||
use crate::id3::find_id3v2;
|
||||
|
@ -157,7 +157,7 @@ pub(super) fn create_tag<'a, I: Iterator<Item = FrameRef<'a>> + 'a>(
|
|||
Ok(id3v2.into_inner())
|
||||
}
|
||||
|
||||
fn create_tag_header(flags: ID3v2TagFlags) -> Result<(Cursor<Vec<u8>>, u32)> {
|
||||
fn create_tag_header(flags: Id3v2TagFlags) -> Result<(Cursor<Vec<u8>>, u32)> {
|
||||
let mut header = Cursor::new(Vec::new());
|
||||
|
||||
header.write_all(&[b'I', b'D', b'3'])?;
|
||||
|
@ -253,7 +253,7 @@ fn calculate_crc(content: &[u8]) -> [u8; 5] {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::id3::v2::{ID3v2TagFlags, Id3v2Tag};
|
||||
use crate::id3::v2::{Id3v2Tag, Id3v2TagFlags};
|
||||
use crate::{Accessor, TagExt};
|
||||
|
||||
#[test]
|
||||
|
@ -261,9 +261,9 @@ mod tests {
|
|||
let mut tag = Id3v2Tag::default();
|
||||
tag.set_artist(String::from("Foo artist"));
|
||||
|
||||
let flags = ID3v2TagFlags {
|
||||
let flags = Id3v2TagFlags {
|
||||
crc: true,
|
||||
..ID3v2TagFlags::default()
|
||||
..Id3v2TagFlags::default()
|
||||
};
|
||||
tag.set_flags(flags);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{aac, ape, flac, iff, mpeg, wavpack};
|
|||
|
||||
use crate::id3::v1::tag::Id3v1TagRef;
|
||||
use crate::id3::v2::tag::Id3v2TagRef;
|
||||
use crate::id3::v2::{self, ID3v2TagFlags};
|
||||
use crate::id3::v2::{self, Id3v2TagFlags};
|
||||
use crate::mp4::Ilst;
|
||||
use crate::ogg::tag::{create_vorbis_comments_ref, VorbisCommentsRef};
|
||||
use ape::tag::ApeTagRef;
|
||||
|
@ -46,7 +46,7 @@ pub(crate) fn dump_tag<W: Write>(tag: &Tag, writer: &mut W) -> Result<()> {
|
|||
.dump_to(writer),
|
||||
TagType::Id3v1 => Into::<Id3v1TagRef<'_>>::into(tag).dump_to(writer),
|
||||
TagType::Id3v2 => Id3v2TagRef {
|
||||
flags: ID3v2TagFlags::default(),
|
||||
flags: Id3v2TagFlags::default(),
|
||||
frames: v2::tag::tag_frames(tag),
|
||||
}
|
||||
.dump_to(writer),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use lofty::id3::v2::{AttachedPictureFrame, ID3v2Version};
|
||||
use lofty::id3::v2::{AttachedPictureFrame, Id3v2Version};
|
||||
use lofty::{Picture, PictureInformation, PictureType, TextEncoding};
|
||||
|
||||
use std::fs::File;
|
||||
|
@ -28,7 +28,7 @@ fn create_original_picture() -> Picture {
|
|||
fn id3v24_apic() {
|
||||
let buf = get_buf("tests/picture/assets/png_640x628.apic");
|
||||
|
||||
let apic = AttachedPictureFrame::parse(&mut &buf[..], ID3v2Version::V4).unwrap();
|
||||
let apic = AttachedPictureFrame::parse(&mut &buf[..], Id3v2Version::V4).unwrap();
|
||||
|
||||
assert_eq!(create_original_picture(), apic.picture);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ fn as_apic_bytes() {
|
|||
picture: original_picture,
|
||||
};
|
||||
|
||||
let original_as_apic = apic.as_bytes(ID3v2Version::V4).unwrap();
|
||||
let original_as_apic = apic.as_bytes(Id3v2Version::V4).unwrap();
|
||||
|
||||
assert_eq!(buf, original_as_apic);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ fn as_apic_bytes() {
|
|||
fn id3v22_pic() {
|
||||
let buf = get_buf("tests/picture/assets/png_640x628.pic");
|
||||
|
||||
let pic = AttachedPictureFrame::parse(&mut &buf[..], ID3v2Version::V2).unwrap();
|
||||
let pic = AttachedPictureFrame::parse(&mut &buf[..], Id3v2Version::V2).unwrap();
|
||||
|
||||
assert_eq!(create_original_picture(), pic.picture);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ fn as_apic_bytes_v2() {
|
|||
picture: original_picture,
|
||||
};
|
||||
|
||||
let original_as_pic = pic.as_bytes(ID3v2Version::V2).unwrap();
|
||||
let original_as_pic = pic.as_bytes(Id3v2Version::V2).unwrap();
|
||||
|
||||
assert_eq!(buf, original_as_pic);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue