ID3v2: Properly capitalize Id3v2TagFlags

This commit is contained in:
Serial 2022-06-26 11:38:17 -04:00
parent 624c441b59
commit a4e62d674c
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
9 changed files with 23 additions and 22 deletions

View file

@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Id3v2Error` -> `ID3v2Error`
- `Id3v2ErrorKind` -> `ID3v2ErrorKind`
- `ErrorKind::Id3v2` -> `ErrorKind::ID3v2`
- `Id3v2TagFlags` -> `ID3v2TagFlags`
- Properly capitalized the variants of `TagType`
- `Ape` -> `APE`
- `Id3v1` -> `ID3v1`

View file

@ -4,7 +4,7 @@ use super::restrictions::TagRestrictions;
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
#[allow(clippy::struct_excessive_bools)]
/// Flags that apply to the entire tag
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

View file

@ -18,7 +18,7 @@ use byteorder::{BigEndian, ByteOrder, ReadBytesExt};
cfg_if::cfg_if! {
if #[cfg(feature = "id3v2")] {
pub use flags::Id3v2TagFlags;
pub use flags::ID3v2TagFlags;
pub use util::text_utils::TextEncoding;
pub use util::upgrade::{upgrade_v2, upgrade_v3};
@ -52,7 +52,7 @@ cfg_if::cfg_if! {
}
#[cfg(not(feature = "id3v2"))]
use flags::Id3v2TagFlags;
use flags::ID3v2TagFlags;
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
/// The ID3v2 version
@ -87,7 +87,7 @@ pub(crate) fn synch_u32(n: u32) -> Result<u32> {
pub(crate) struct Id3v2Header {
#[cfg(feature = "id3v2")]
pub version: Id3v2Version,
pub flags: Id3v2TagFlags,
pub flags: ID3v2TagFlags,
pub size: u32,
pub extended_size: u32,
}
@ -125,7 +125,7 @@ where
.into());
}
let mut flags_parsed = Id3v2TagFlags {
let mut flags_parsed = ID3v2TagFlags {
unsynchronisation: flags & 0x80 == 0x80,
experimental: (version == Id3v2Version::V4 || version == Id3v2Version::V3)
&& flags & 0x20 == 0x20,

View file

@ -1,4 +1,4 @@
use super::flags::Id3v2TagFlags;
use super::flags::ID3v2TagFlags;
use super::frame::id::FrameID;
use super::frame::{Frame, FrameFlags, FrameValue};
use super::util::text_utils::TextEncoding;
@ -92,7 +92,7 @@ macro_rules! impl_accessor {
/// [`GeneralEncapsulatedObject::as_bytes`](crate::id3::v2::GeneralEncapsulatedObject::as_bytes) and
/// [`SynchronizedText::as_bytes`](crate::id3::v2::SynchronizedText::as_bytes) for writing.
pub struct Id3v2Tag {
flags: Id3v2TagFlags,
flags: ID3v2TagFlags,
pub(super) original_version: Id3v2Version,
frames: Vec<Frame>,
}
@ -109,7 +109,7 @@ impl IntoIterator for Id3v2Tag {
impl Default for Id3v2Tag {
fn default() -> Self {
Self {
flags: Id3v2TagFlags::default(),
flags: ID3v2TagFlags::default(),
original_version: Id3v2Version::V4,
frames: Vec::new(),
}
@ -118,12 +118,12 @@ impl Default for Id3v2Tag {
impl Id3v2Tag {
/// Returns the [`Id3v2TagFlags`]
pub fn flags(&self) -> &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
}
@ -594,14 +594,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(),
}
}

View file

@ -1,7 +1,7 @@
mod chunk_file;
mod frame;
use super::Id3v2TagFlags;
use super::ID3v2TagFlags;
use crate::error::{ErrorKind, LoftyError, Result};
use crate::file::FileType;
use crate::id3::find_id3v2;
@ -138,7 +138,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'])?;
@ -239,7 +239,7 @@ fn calculate_crc(content: &[u8]) -> [u8; 5] {
#[cfg(test)]
mod tests {
use crate::id3::v2::{Id3v2Tag, Id3v2TagFlags};
use crate::id3::v2::{ID3v2TagFlags, Id3v2Tag};
use crate::{Accessor, TagExt};
#[test]
@ -247,9 +247,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);

View file

@ -24,7 +24,7 @@ pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
.write_to(data),
#[cfg(feature = "id3v2")]
TagType::ID3v2 => v2::tag::Id3v2TagRef {
flags: v2::Id3v2TagFlags::default(),
flags: v2::ID3v2TagFlags::default(),
frames: v2::tag::tag_frames(tag),
}
.write_to(data),

View file

@ -16,7 +16,7 @@ pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
},
#[cfg(feature = "id3v2")]
TagType::ID3v2 => v2::tag::Id3v2TagRef {
flags: v2::Id3v2TagFlags::default(),
flags: v2::ID3v2TagFlags::default(),
frames: v2::tag::tag_frames(tag),
}
.write_to(data),

View file

@ -23,7 +23,7 @@ pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> {
TagType::ID3v1 => Into::<v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(data),
#[cfg(feature = "id3v2")]
TagType::ID3v2 => v2::tag::Id3v2TagRef {
flags: v2::Id3v2TagFlags::default(),
flags: v2::ID3v2TagFlags::default(),
frames: v2::tag::tag_frames(tag),
}
.write_to(data),

View file

@ -6,7 +6,7 @@ use crate::{ape, iff, mp3, wavpack};
#[cfg(feature = "id3v1")]
use crate::id3::v1::tag::Id3v1TagRef;
#[cfg(feature = "id3v2")]
use crate::id3::v2::{self, tag::Id3v2TagRef, Id3v2TagFlags};
use crate::id3::v2::{self, tag::Id3v2TagRef, ID3v2TagFlags};
#[cfg(feature = "mp4_ilst")]
use crate::mp4::Ilst;
#[cfg(feature = "vorbis_comments")]
@ -54,7 +54,7 @@ pub(crate) fn dump_tag<W: Write>(tag: &Tag, writer: &mut W) -> Result<()> {
TagType::ID3v1 => Into::<Id3v1TagRef<'_>>::into(tag).dump_to(writer),
#[cfg(feature = "id3v2")]
TagType::ID3v2 => Id3v2TagRef {
flags: Id3v2TagFlags::default(),
flags: ID3v2TagFlags::default(),
frames: v2::tag::tag_frames(tag),
}
.dump_to(writer),