From f8b011bbba7a447812d6ca18951052b9f41cef95 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Sun, 26 Jun 2022 11:51:52 -0400 Subject: [PATCH] WAV: Properly capitalize `RIFFInfoList` --- CHANGELOG.md | 1 + benches/create_tag.rs | 4 ++-- src/iff/mod.rs | 2 +- src/iff/wav/mod.rs | 6 +++--- src/iff/wav/read.rs | 4 ++-- src/iff/wav/tag/mod.rs | 42 ++++++++++++++++++++-------------------- src/iff/wav/tag/read.rs | 4 ++-- src/iff/wav/tag/write.rs | 4 ++-- src/iff/wav/write.rs | 2 +- src/tag/utils.rs | 4 ++-- 10 files changed, 37 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef3a417f..78b82855 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **MP4**: `Ilst::track_number` has been moved to the `Accessor::track` implementation - **Tag**: Renamed `Tag::get_texts` to `Tag::get_strings` - **AIFF**: Renamed `AiffTextChunks` -> `AIFFTextChunks` +- **WAV**: Renamed `RiffInfoList` -> `RIFFInfoList` ### Fixed - **AIFF**: Fixed division by zero panic during property reading ([issue](https://github.com/Serial-ATA/lofty-rs/issues/56)) diff --git a/benches/create_tag.rs b/benches/create_tag.rs index 65d8d9b2..2f40cf2a 100644 --- a/benches/create_tag.rs +++ b/benches/create_tag.rs @@ -1,7 +1,7 @@ use lofty::ape::ApeTag; use lofty::id3::v1::ID3v1Tag; use lofty::id3::v2::ID3v2Tag; -use lofty::iff::{AIFFTextChunks, RiffInfoList}; +use lofty::iff::{AIFFTextChunks, RIFFInfoList}; use lofty::mp4::Ilst; use lofty::ogg::VorbisComments; use lofty::{Accessor, TagExt}; @@ -27,7 +27,7 @@ bench_tag_write!(ape, ApeTag); bench_tag_write!(id3v2, ID3v2Tag); bench_tag_write!(id3v1, ID3v1Tag); bench_tag_write!(ilst, Ilst); -bench_tag_write!(riff_info, RiffInfoList); +bench_tag_write!(riff_info, RIFFInfoList); bench_tag_write!(vorbis_comments, VorbisComments); fn bench_write(c: &mut Criterion) { diff --git a/src/iff/mod.rs b/src/iff/mod.rs index 7f4944d4..f65f7cc4 100644 --- a/src/iff/mod.rs +++ b/src/iff/mod.rs @@ -17,6 +17,6 @@ cfg_if::cfg_if! { cfg_if::cfg_if! { if #[cfg(feature = "riff_info_list")] { - pub use wav::tag::RiffInfoList; + pub use wav::tag::RIFFInfoList; } } diff --git a/src/iff/wav/mod.rs b/src/iff/wav/mod.rs index dc9d7e80..3071e3e8 100644 --- a/src/iff/wav/mod.rs +++ b/src/iff/wav/mod.rs @@ -14,7 +14,7 @@ use std::io::{Read, Seek}; cfg_if::cfg_if! { if #[cfg(feature = "riff_info_list")] { pub(crate) mod tag; - use tag::RiffInfoList; + use tag::RIFFInfoList; } } @@ -25,7 +25,7 @@ pub use crate::iff::wav::properties::{WavFormat, WavProperties}; pub struct WavFile { #[cfg(feature = "riff_info_list")] /// A RIFF INFO LIST - pub(crate) riff_info: Option, + pub(crate) riff_info: Option, #[cfg(feature = "id3v2")] /// An ID3v2 tag pub(crate) id3v2_tag: Option, @@ -94,6 +94,6 @@ impl WavFile { id3v2_tag, ID3v2Tag; #[cfg(feature = "riff_info_list")] - riff_info, RiffInfoList + riff_info, RIFFInfoList } } diff --git a/src/iff/wav/read.rs b/src/iff/wav/read.rs index 0143c621..78595e5c 100644 --- a/src/iff/wav/read.rs +++ b/src/iff/wav/read.rs @@ -1,6 +1,6 @@ use super::properties::WavProperties; #[cfg(feature = "riff_info_list")] -use super::tag::RiffInfoList; +use super::tag::RIFFInfoList; use super::WavFile; use crate::error::{FileDecodingError, Result}; use crate::file::FileType; @@ -47,7 +47,7 @@ where let mut fmt = Vec::new(); #[cfg(feature = "riff_info_list")] - let mut riff_info = RiffInfoList::default(); + let mut riff_info = RIFFInfoList::default(); #[cfg(feature = "id3v2")] let mut id3v2_tag: Option = None; diff --git a/src/iff/wav/tag/mod.rs b/src/iff/wav/tag/mod.rs index 6876f172..5bdb2b5f 100644 --- a/src/iff/wav/tag/mod.rs +++ b/src/iff/wav/tag/mod.rs @@ -45,12 +45,12 @@ macro_rules! impl_accessor { /// /// * The [`TagItem`] has a value other than [`ItemValue::Binary`](crate::ItemValue::Binary) /// * It has a key that is 4 bytes in length and within the ASCII range -pub struct RiffInfoList { +pub struct RIFFInfoList { /// A collection of chunk-value pairs pub(crate) items: Vec<(String, String)>, } -impl RiffInfoList { +impl RIFFInfoList { /// Get an item by key pub fn get(&self, key: &str) -> Option<&str> { self.items @@ -90,7 +90,7 @@ impl RiffInfoList { } } -impl Accessor for RiffInfoList { +impl Accessor for RIFFInfoList { impl_accessor!( artist => "IART"; title => "INAM"; @@ -132,7 +132,7 @@ impl Accessor for RiffInfoList { } } -impl TagExt for RiffInfoList { +impl TagExt for RIFFInfoList { type Err = LoftyError; fn is_empty(&self) -> bool { @@ -144,12 +144,12 @@ impl TagExt for RiffInfoList { } fn save_to(&self, file: &mut File) -> std::result::Result<(), Self::Err> { - RiffInfoListRef::new(self.items.iter().map(|(k, v)| (k.as_str(), v.as_str()))) + RIFFInfoListRef::new(self.items.iter().map(|(k, v)| (k.as_str(), v.as_str()))) .write_to(file) } fn dump_to(&self, writer: &mut W) -> std::result::Result<(), Self::Err> { - RiffInfoListRef::new(self.items.iter().map(|(k, v)| (k.as_str(), v.as_str()))) + RIFFInfoListRef::new(self.items.iter().map(|(k, v)| (k.as_str(), v.as_str()))) .dump_to(writer) } @@ -166,8 +166,8 @@ impl TagExt for RiffInfoList { } } -impl From for Tag { - fn from(input: RiffInfoList) -> Self { +impl From for Tag { + fn from(input: RIFFInfoList) -> Self { let mut tag = Tag::new(TagType::RIFFInfo); for (k, v) in input.items { @@ -183,9 +183,9 @@ impl From for Tag { } } -impl From for RiffInfoList { +impl From for RIFFInfoList { fn from(input: Tag) -> Self { - let mut riff_info = RiffInfoList::default(); + let mut riff_info = RIFFInfoList::default(); for item in input.items { if let ItemValue::Text(val) | ItemValue::Locator(val) = item.item_value { @@ -208,19 +208,19 @@ impl From for RiffInfoList { } } -pub(crate) struct RiffInfoListRef<'a, I> +pub(crate) struct RIFFInfoListRef<'a, I> where I: Iterator, { pub(crate) items: I, } -impl<'a, I> RiffInfoListRef<'a, I> +impl<'a, I> RIFFInfoListRef<'a, I> where I: Iterator, { - pub(crate) fn new(items: I) -> RiffInfoListRef<'a, I> { - RiffInfoListRef { items } + pub(crate) fn new(items: I) -> RIFFInfoListRef<'a, I> { + RIFFInfoListRef { items } } pub(crate) fn write_to(&mut self, file: &mut File) -> Result<()> { @@ -254,7 +254,7 @@ pub(crate) fn tagitems_into_riff(items: &[TagItem]) -> impl Iterator( data: &mut R, chunks: &mut Chunks, end: u64, - tag: &mut RiffInfoList, + tag: &mut RIFFInfoList, ) -> Result<()> where R: Read + Seek, diff --git a/src/iff/wav/tag/write.rs b/src/iff/wav/tag/write.rs index 3c036982..f9328a55 100644 --- a/src/iff/wav/tag/write.rs +++ b/src/iff/wav/tag/write.rs @@ -1,4 +1,4 @@ -use super::RiffInfoListRef; +use super::RIFFInfoListRef; use crate::error::{ErrorKind, LoftyError, Result}; use crate::iff::chunk::Chunks; use crate::iff::wav::read::verify_wav; @@ -10,7 +10,7 @@ use byteorder::{LittleEndian, WriteBytesExt}; pub(in crate::iff::wav) fn write_riff_info<'a, I>( data: &mut File, - tag: &mut RiffInfoListRef<'a, I>, + tag: &mut RIFFInfoListRef<'a, I>, ) -> Result<()> where I: Iterator, diff --git a/src/iff/wav/write.rs b/src/iff/wav/write.rs index 4d2a9ab7..4f310ea1 100644 --- a/src/iff/wav/write.rs +++ b/src/iff/wav/write.rs @@ -11,7 +11,7 @@ pub(crate) fn write_to(data: &mut File, tag: &Tag) -> Result<()> { match tag.tag_type() { #[cfg(feature = "riff_info_list")] TagType::RIFFInfo => { - super::tag::RiffInfoListRef::new(super::tag::tagitems_into_riff(tag.items())) + super::tag::RIFFInfoListRef::new(super::tag::tagitems_into_riff(tag.items())) .write_to(data) }, #[cfg(feature = "id3v2")] diff --git a/src/tag/utils.rs b/src/tag/utils.rs index 8ecc409a..05d74001 100644 --- a/src/tag/utils.rs +++ b/src/tag/utils.rs @@ -16,7 +16,7 @@ use ape::tag::ApeTagRef; #[cfg(feature = "aiff_text_chunks")] use iff::aiff::tag::AiffTextChunksRef; #[cfg(feature = "riff_info_list")] -use iff::wav::tag::RiffInfoListRef; +use iff::wav::tag::RIFFInfoListRef; use std::fs::File; use std::io::Write; @@ -72,7 +72,7 @@ pub(crate) fn dump_tag(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),