mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-03-04 14:57:17 +00:00
AIFF: Properly capitalize AIFFTextChunks
This commit is contained in:
parent
a3e7a81c2e
commit
5a30964228
6 changed files with 24 additions and 23 deletions
|
@ -40,8 +40,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `RiffInfo` -> `RIFFInfo`
|
||||
- `AiffText` -> `AIFFText`
|
||||
- All types implementing `PartialEq` now implement `Eq`
|
||||
- `Ilst::track_number` has been moved to the `Accessor::track` implementation
|
||||
- Renamed `Tag::get_texts` to `Tag::get_strings`
|
||||
- **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`
|
||||
|
||||
### Fixed
|
||||
- **AIFF**: Fixed division by zero panic during property reading ([issue](https://github.com/Serial-ATA/lofty-rs/issues/56))
|
||||
|
|
|
@ -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};
|
||||
|
@ -22,7 +22,7 @@ macro_rules! bench_tag_write {
|
|||
};
|
||||
}
|
||||
|
||||
bench_tag_write!(aiff_text, AiffTextChunks);
|
||||
bench_tag_write!(aiff_text, AIFFTextChunks);
|
||||
bench_tag_write!(ape, ApeTag);
|
||||
bench_tag_write!(id3v2, ID3v2Tag);
|
||||
bench_tag_write!(id3v1, ID3v1Tag);
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::io::{Read, Seek};
|
|||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "aiff_text_chunks")] {
|
||||
pub(crate) mod tag;
|
||||
use tag::AiffTextChunks;
|
||||
use tag::AIFFTextChunks;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ cfg_if::cfg_if! {
|
|||
pub struct AiffFile {
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
/// Any text chunks included in the file
|
||||
pub(crate) text_chunks: Option<AiffTextChunks>,
|
||||
pub(crate) text_chunks: Option<AIFFTextChunks>,
|
||||
#[cfg(feature = "id3v2")]
|
||||
/// An ID3v2 tag
|
||||
pub(crate) id3v2_tag: Option<ID3v2Tag>,
|
||||
|
@ -90,6 +90,6 @@ impl AiffFile {
|
|||
id3v2_tag, ID3v2Tag;
|
||||
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
text_chunks, AiffTextChunks
|
||||
text_chunks, AIFFTextChunks
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#[cfg(feature = "aiff_text_chunks")]
|
||||
use super::tag::{AiffTextChunks, Comment};
|
||||
use super::tag::{AIFFTextChunks, Comment};
|
||||
use super::AiffFile;
|
||||
use crate::error::{ErrorKind, FileDecodingError, LoftyError, Result};
|
||||
use crate::file::FileType;
|
||||
|
@ -40,7 +40,7 @@ where
|
|||
let mut stream_len = 0;
|
||||
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
let mut text_chunks = AiffTextChunks::default();
|
||||
let mut text_chunks = AIFFTextChunks::default();
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
let mut annotations = Vec::new();
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
|
@ -158,7 +158,7 @@ where
|
|||
properties,
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
text_chunks: match text_chunks {
|
||||
AiffTextChunks {
|
||||
AIFFTextChunks {
|
||||
name: None,
|
||||
author: None,
|
||||
copyright: None,
|
||||
|
|
|
@ -60,7 +60,7 @@ pub struct Comment {
|
|||
///
|
||||
/// When converting [Comment]s, only the `text` field will be preserved.
|
||||
#[derive(Default, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct AiffTextChunks {
|
||||
pub struct AIFFTextChunks {
|
||||
/// The name of the piece
|
||||
pub name: Option<String>,
|
||||
/// The author of the piece
|
||||
|
@ -79,7 +79,7 @@ pub struct AiffTextChunks {
|
|||
pub comments: Option<Vec<Comment>>,
|
||||
}
|
||||
|
||||
impl Accessor for AiffTextChunks {
|
||||
impl Accessor for AIFFTextChunks {
|
||||
fn artist(&self) -> Option<&str> {
|
||||
self.author.as_deref()
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ impl Accessor for AiffTextChunks {
|
|||
}
|
||||
}
|
||||
|
||||
impl AiffTextChunks {
|
||||
impl AIFFTextChunks {
|
||||
/// Returns the copyright message
|
||||
pub fn copyright(&self) -> Option<&str> {
|
||||
self.copyright.as_deref()
|
||||
|
@ -138,13 +138,13 @@ impl AiffTextChunks {
|
|||
}
|
||||
}
|
||||
|
||||
impl TagExt for AiffTextChunks {
|
||||
impl TagExt for AIFFTextChunks {
|
||||
type Err = LoftyError;
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
AiffTextChunks {
|
||||
AIFFTextChunks {
|
||||
name: None,
|
||||
author: None,
|
||||
copyright: None,
|
||||
|
@ -159,7 +159,7 @@ impl TagExt for AiffTextChunks {
|
|||
/// # Errors
|
||||
///
|
||||
/// * `path` does not exist
|
||||
/// * See [`AiffTextChunks::save_to`]
|
||||
/// * See [`AIFFTextChunks::save_to`]
|
||||
fn save_to_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
|
||||
self.save_to(&mut OpenOptions::new().read(true).write(true).open(path)?)
|
||||
}
|
||||
|
@ -199,8 +199,8 @@ impl TagExt for AiffTextChunks {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<AiffTextChunks> for Tag {
|
||||
fn from(input: AiffTextChunks) -> Self {
|
||||
impl From<AIFFTextChunks> for Tag {
|
||||
fn from(input: AIFFTextChunks) -> Self {
|
||||
let mut tag = Tag::new(TagType::AIFFText);
|
||||
|
||||
let push_item = |field: Option<String>, item_key: ItemKey, tag: &mut Tag| {
|
||||
|
@ -232,7 +232,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();
|
||||
|
@ -422,14 +422,14 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::iff::{AiffTextChunks, Comment};
|
||||
use crate::iff::{AIFFTextChunks, Comment};
|
||||
use crate::{ItemKey, ItemValue, Tag, TagExt, 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")),
|
||||
|
@ -525,7 +525,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")));
|
||||
|
|
|
@ -10,7 +10,7 @@ pub use wav::{WavFile, WavFormat, WavProperties};
|
|||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "aiff_text_chunks")] {
|
||||
pub use aiff::tag::AiffTextChunks;
|
||||
pub use aiff::tag::AIFFTextChunks;
|
||||
pub use aiff::tag::Comment;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue