Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iff: Rename IFF tags #379

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `PictureType`
- `PictureInformation`
- `MimeType`
- **IFF** ([PR](https://github.com/Serial-ATA/lofty-rs/pull/379)):
- **AIFF**: `AIFFTextChunks` renamed to `AiffTextChunks`
- **RIFF**: `RIFFInfoList` renamed to `RiffInfoList`

### Fixed
- **Vorbis**: Fix panic when reading properties of zero-length files ([issue](https://github.com/Serial-ATA/lofty-rs/issues/342)) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/365))
Expand Down
8 changes: 4 additions & 4 deletions benches/create_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use lofty::ape::ApeTag;
use lofty::config::WriteOptions;
use lofty::id3::v1::Id3v1Tag;
use lofty::id3::v2::Id3v2Tag;
use lofty::iff::aiff::AIFFTextChunks;
use lofty::iff::wav::RIFFInfoList;
use lofty::iff::aiff::AiffTextChunks;
use lofty::iff::wav::RiffInfoList;
use lofty::mp4::Ilst;
use lofty::ogg::VorbisComments;
use lofty::picture::{MimeType, Picture, PictureType};
Expand Down Expand Up @@ -35,7 +35,7 @@ macro_rules! bench_tag_write {
}

bench_tag_write!([
(aiff_text_chunks, AIFFTextChunks, |tag| {}),
(aiff_text_chunks, AiffTextChunks, |tag| {}),
(apev2, ApeTag, |tag| {
use lofty::ape::ApeItem;
use lofty::tag::ItemValue;
Expand Down Expand Up @@ -103,7 +103,7 @@ bench_tag_write!([
AtomData::UTF8(String::from(ENCODER)),
));
}),
(riff_info, RIFFInfoList, |tag| {
(riff_info, RiffInfoList, |tag| {
tag.insert(String::from("ISFT"), String::from(ENCODER));
}),
(vorbis_comments, VorbisComments, |tag| {
Expand Down
4 changes: 2 additions & 2 deletions src/file/file_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ impl FileType {
TagType::Id3v2 => crate::id3::v2::Id3v2Tag::SUPPORTED_FORMATS.contains(self),
TagType::Mp4Ilst => crate::mp4::Ilst::SUPPORTED_FORMATS.contains(self),
TagType::VorbisComments => crate::ogg::VorbisComments::SUPPORTED_FORMATS.contains(self),
TagType::RiffInfo => crate::iff::wav::RIFFInfoList::SUPPORTED_FORMATS.contains(self),
TagType::AiffText => crate::iff::aiff::AIFFTextChunks::SUPPORTED_FORMATS.contains(self),
TagType::RiffInfo => crate::iff::wav::RiffInfoList::SUPPORTED_FORMATS.contains(self),
TagType::AiffText => crate::iff::aiff::AiffTextChunks::SUPPORTED_FORMATS.contains(self),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/iff/aiff/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use lofty_attr::LoftyFile;
// Exports

pub use properties::{AiffCompressionType, AiffProperties};
pub use tag::{AIFFTextChunks, Comment};
pub use tag::{AiffTextChunks, Comment};

/// An AIFF file
#[derive(LoftyFile)]
Expand All @@ -20,7 +20,7 @@ pub use tag::{AIFFTextChunks, Comment};
pub struct AiffFile {
/// Any text chunks included in the file
#[lofty(tag_type = "AiffText")]
pub(crate) text_chunks_tag: Option<AIFFTextChunks>,
pub(crate) text_chunks_tag: Option<AiffTextChunks>,
/// An ID3v2 tag
#[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<Id3v2Tag>,
Expand Down
6 changes: 3 additions & 3 deletions src/iff/aiff/read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::properties::AiffProperties;
use super::tag::{AIFFTextChunks, Comment};
use super::tag::{AiffTextChunks, Comment};
use super::AiffFile;
use crate::config::ParseOptions;
use crate::error::Result;
Expand Down Expand Up @@ -59,7 +59,7 @@ where
let mut comm = None;
let mut stream_len = 0;

let mut text_chunks = AIFFTextChunks::default();
let mut text_chunks = AiffTextChunks::default();
let mut annotations = Vec::new();
let mut comments = Vec::new();

Expand Down Expand Up @@ -168,7 +168,7 @@ where
Ok(AiffFile {
properties,
text_chunks_tag: match text_chunks {
AIFFTextChunks {
AiffTextChunks {
name: None,
author: None,
copyright: None,
Expand Down
30 changes: 15 additions & 15 deletions src/iff/aiff/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct Comment {
/// Every item with the key [`ItemKey::Comment`] will be stored as an annotation.
#[derive(Default, Clone, Debug, PartialEq, Eq)]
#[tag(description = "`AIFF` text chunks", supported_formats(Aiff))]
pub struct AIFFTextChunks {
pub struct AiffTextChunks {
/// The name of the piece
pub name: Option<String>,
/// The author of the piece
Expand All @@ -78,7 +78,7 @@ pub struct AIFFTextChunks {
pub comments: Option<Vec<Comment>>,
}

impl Accessor for AIFFTextChunks {
impl Accessor for AiffTextChunks {
fn artist(&self) -> Option<Cow<'_, str>> {
self.author.as_deref().map(Cow::Borrowed)
}
Expand Down Expand Up @@ -120,16 +120,16 @@ impl Accessor for AIFFTextChunks {
}
}

impl AIFFTextChunks {
impl AiffTextChunks {
/// Create a new empty `AIFFTextChunks`
///
/// # Examples
///
/// ```rust
/// use lofty::iff::aiff::AIFFTextChunks;
/// use lofty::iff::aiff::AiffTextChunks;
/// use lofty::tag::TagExt;
///
/// let aiff_tag = AIFFTextChunks::new();
/// let aiff_tag = AiffTextChunks::new();
/// assert!(aiff_tag.is_empty());
/// ```
pub fn new() -> Self {
Expand All @@ -152,7 +152,7 @@ impl AIFFTextChunks {
}
}

impl TagExt for AIFFTextChunks {
impl TagExt for AiffTextChunks {
type Err = LoftyError;
type RefKey<'a> = &'a ItemKey;

Expand Down Expand Up @@ -182,7 +182,7 @@ impl TagExt for AIFFTextChunks {
fn is_empty(&self) -> bool {
matches!(
self,
AIFFTextChunks {
AiffTextChunks {
name: None,
author: None,
copyright: None,
Expand Down Expand Up @@ -235,7 +235,7 @@ impl TagExt for AIFFTextChunks {
#[derive(Debug, Clone, Default)]
pub struct SplitTagRemainder;

impl SplitTag for AIFFTextChunks {
impl SplitTag for AiffTextChunks {
type Remainder = SplitTagRemainder;

fn split_tag(self) -> (Self::Remainder, Tag) {
Expand All @@ -244,15 +244,15 @@ impl SplitTag for AIFFTextChunks {
}

impl MergeTag for SplitTagRemainder {
type Merged = AIFFTextChunks;
type Merged = AiffTextChunks;

fn merge_tag(self, tag: Tag) -> Self::Merged {
tag.into()
}
}

impl From<AIFFTextChunks> for Tag {
fn from(input: AIFFTextChunks) -> Self {
impl From<AiffTextChunks> for Tag {
fn from(input: AiffTextChunks) -> Self {
let mut tag = Self::new(TagType::AiffText);

let push_item = |field: Option<String>, item_key: ItemKey, tag: &mut Tag| {
Expand Down Expand Up @@ -284,7 +284,7 @@ impl From<AIFFTextChunks> for Tag {
}
}

impl From<Tag> for AIFFTextChunks {
impl From<Tag> for AiffTextChunks {
fn from(mut input: Tag) -> Self {
let name = input.take_strings(&ItemKey::TrackTitle).next();
let author = input.take_strings(&ItemKey::TrackArtist).next();
Expand Down Expand Up @@ -494,15 +494,15 @@ where
#[cfg(test)]
mod tests {
use crate::config::{ParseOptions, WriteOptions};
use crate::iff::aiff::{AIFFTextChunks, Comment};
use crate::iff::aiff::{AiffTextChunks, Comment};
use crate::prelude::*;
use crate::tag::{ItemValue, Tag, TagItem, TagType};

use std::io::Cursor;

#[test]
fn parse_aiff_text() {
let expected_tag = AIFFTextChunks {
let expected_tag = AiffTextChunks {
name: Some(String::from("Foo title")),
author: Some(String::from("Bar artist")),
copyright: Some(String::from("Baz copyright")),
Expand Down Expand Up @@ -612,7 +612,7 @@ mod tests {
ItemValue::Text(String::from("Quux annotation")),
));

let aiff_text: AIFFTextChunks = tag.into();
let aiff_text: AiffTextChunks = tag.into();

assert_eq!(aiff_text.name, Some(String::from("Foo title")));
assert_eq!(aiff_text.author, Some(String::from("Bar artist")));
Expand Down
4 changes: 2 additions & 2 deletions src/iff/wav/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use lofty_attr::LoftyFile;

// Exports
pub use crate::iff::wav::properties::{WavFormat, WavProperties};
pub use tag::RIFFInfoList;
pub use tag::RiffInfoList;

/// A WAV file
#[derive(LoftyFile)]
Expand All @@ -19,7 +19,7 @@ pub use tag::RIFFInfoList;
pub struct WavFile {
/// A RIFF INFO LIST
#[lofty(tag_type = "RiffInfo")]
pub(crate) riff_info_tag: Option<RIFFInfoList>,
pub(crate) riff_info_tag: Option<RiffInfoList>,
/// An ID3v2 tag
#[lofty(tag_type = "Id3v2")]
pub(crate) id3v2_tag: Option<Id3v2Tag>,
Expand Down
4 changes: 2 additions & 2 deletions src/iff/wav/read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::properties::WavProperties;
use super::tag::RIFFInfoList;
use super::tag::RiffInfoList;
use super::WavFile;
use crate::config::ParseOptions;
use crate::error::Result;
Expand Down Expand Up @@ -45,7 +45,7 @@ where
let mut total_samples = 0_u32;
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 chunks = Chunks::<LittleEndian>::new(file_len);
Expand Down
Loading