mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-03-04 14:57:17 +00:00
iff: Separate wav
and aiff
into their own modules
This commit is contained in:
parent
b2da52196a
commit
afe78368c2
14 changed files with 30 additions and 38 deletions
|
@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- **lofty_attr**: Simplified the `file_type` attribute:
|
||||
- Before, you had to specify custom file types as `#[lofty(file_type = "Custom(\"MyFile\")")]`. Now
|
||||
you can simply do `#[lofty(file_type = "MyFile")]` and it will infer the rest.
|
||||
- **IFF**: `WAV` and `AIFF` items are no longer combined in the `iff` module. They are now separated
|
||||
into their own modules at `iff::wav` and `iff::aiff` respectively.
|
||||
|
||||
### Removed
|
||||
- **lofty_attr**: The `#[lofty(always_present)]` attribute has been removed, and is now inferred.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use lofty::ape::ApeTag;
|
||||
use lofty::id3::v1::ID3v1Tag;
|
||||
use lofty::id3::v2::ID3v2Tag;
|
||||
use lofty::iff::{AIFFTextChunks, RIFFInfoList};
|
||||
use lofty::iff::aiff::AIFFTextChunks;
|
||||
use lofty::iff::wav::RIFFInfoList;
|
||||
use lofty::mp4::Ilst;
|
||||
use lofty::ogg::VorbisComments;
|
||||
use lofty::{Accessor, TagExt};
|
||||
|
|
|
@ -6,7 +6,7 @@ use libfuzzer_sys::fuzz_target;
|
|||
use lofty::{AudioFile, ParseOptions};
|
||||
|
||||
fuzz_target!(|data: Vec<u8>| {
|
||||
let _ = lofty::iff::AiffFile::read_from(
|
||||
let _ = lofty::iff::aiff::AiffFile::read_from(
|
||||
&mut Cursor::new(data),
|
||||
ParseOptions::new().read_properties(false),
|
||||
);
|
||||
|
|
|
@ -6,7 +6,7 @@ use libfuzzer_sys::fuzz_target;
|
|||
use lofty::{AudioFile, ParseOptions};
|
||||
|
||||
fuzz_target!(|data: Vec<u8>| {
|
||||
let _ = lofty::iff::WavFile::read_from(
|
||||
let _ = lofty::iff::wav::WavFile::read_from(
|
||||
&mut Cursor::new(data),
|
||||
ParseOptions::new().read_properties(false),
|
||||
);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! AIFF specific items
|
||||
|
||||
mod properties;
|
||||
mod read;
|
||||
|
||||
|
@ -7,10 +9,13 @@ use crate::properties::FileProperties;
|
|||
|
||||
use lofty_attr::LoftyFile;
|
||||
|
||||
// Exports
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "aiff_text_chunks")] {
|
||||
pub(crate) mod tag;
|
||||
use tag::AIFFTextChunks;
|
||||
pub use tag::AIFFTextChunks;
|
||||
pub use tag::Comment;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -420,7 +420,7 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::iff::{AIFFTextChunks, Comment};
|
||||
use crate::iff::aiff::{AIFFTextChunks, Comment};
|
||||
use crate::{ItemKey, ItemValue, Tag, TagExt, TagItem, TagType};
|
||||
|
||||
use crate::probe::ParseOptions;
|
||||
|
|
|
@ -1,24 +1,4 @@
|
|||
//! WAV/AIFF specific items
|
||||
pub(crate) mod aiff;
|
||||
pub mod aiff;
|
||||
pub(crate) mod chunk;
|
||||
pub(crate) mod wav;
|
||||
|
||||
// TODO: Expose `iff::{aiff, wav}` instead of combining both here
|
||||
|
||||
// Exports
|
||||
|
||||
pub use aiff::AiffFile;
|
||||
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::Comment;
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "riff_info_list")] {
|
||||
pub use wav::tag::RIFFInfoList;
|
||||
}
|
||||
}
|
||||
pub mod wav;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! WAV specific items
|
||||
|
||||
mod properties;
|
||||
mod read;
|
||||
|
||||
|
@ -6,16 +8,16 @@ use crate::id3::v2::tag::ID3v2Tag;
|
|||
|
||||
use lofty_attr::LoftyFile;
|
||||
|
||||
// Exports
|
||||
pub use crate::iff::wav::properties::{WavFormat, WavProperties};
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "riff_info_list")] {
|
||||
pub(crate) mod tag;
|
||||
use tag::RIFFInfoList;
|
||||
pub use tag::RIFFInfoList;
|
||||
}
|
||||
}
|
||||
|
||||
// Exports
|
||||
pub use crate::iff::wav::properties::{WavFormat, WavProperties};
|
||||
|
||||
/// A WAV file
|
||||
#[derive(LoftyFile)]
|
||||
#[lofty(read_fn = "read::read_from")]
|
||||
|
|
|
@ -251,7 +251,7 @@ pub(crate) fn tagitems_into_riff(items: &[TagItem]) -> impl Iterator<Item = (&st
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::iff::RIFFInfoList;
|
||||
use crate::iff::wav::RIFFInfoList;
|
||||
use crate::{Tag, TagExt, TagType};
|
||||
|
||||
use crate::iff::chunk::Chunks;
|
||||
|
|
|
@ -80,7 +80,8 @@ impl FileProperties {
|
|||
mod tests {
|
||||
use crate::ape::{ApeFile, ApeProperties};
|
||||
use crate::flac::FlacFile;
|
||||
use crate::iff::{AiffFile, WavFile, WavFormat, WavProperties};
|
||||
use crate::iff::aiff::AiffFile;
|
||||
use crate::iff::wav::{WavFile, WavFormat, WavProperties};
|
||||
use crate::mp4::{AudioObjectType, Mp4Codec, Mp4File, Mp4Properties};
|
||||
use crate::mpeg::{ChannelMode, Emphasis, Layer, MPEGFile, MPEGProperties, MpegVersion};
|
||||
use crate::ogg::{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use lofty::ape::ApeFile;
|
||||
use lofty::flac::FlacFile;
|
||||
use lofty::iff::{AiffFile, WavFile};
|
||||
use lofty::iff::aiff::AiffFile;
|
||||
use lofty::iff::wav::WavFile;
|
||||
use lofty::mp4::Mp4File;
|
||||
use lofty::mpeg::MPEGFile;
|
||||
use lofty::{AudioFile, ParseOptions};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::oom_test;
|
||||
use lofty::iff::AiffFile;
|
||||
use lofty::iff::aiff::AiffFile;
|
||||
|
||||
#[test]
|
||||
fn oom1() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::oom_test;
|
||||
use lofty::iff::WavFile;
|
||||
use lofty::iff::wav::WavFile;
|
||||
|
||||
#[test]
|
||||
fn oom1() {
|
||||
|
|
|
@ -3,10 +3,10 @@ use std::fs::File;
|
|||
use std::path::Path;
|
||||
|
||||
use hound::WavReader;
|
||||
use lofty::iff::WavFile;
|
||||
use lofty::iff::wav::WavFile;
|
||||
use lofty::{AudioFile, ParseOptions, Result};
|
||||
|
||||
fn get_properties(path: &Path) -> Result<<lofty::iff::WavFile as AudioFile>::Properties> {
|
||||
fn get_properties(path: &Path) -> Result<<WavFile as AudioFile>::Properties> {
|
||||
let mut f = File::open(path).unwrap();
|
||||
let wav_file = WavFile::read_from(&mut f, ParseOptions::new())?;
|
||||
Ok(*wav_file.properties())
|
||||
|
|
Loading…
Add table
Reference in a new issue