mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-12 13:42:34 +00:00
Make clippy happy
This commit is contained in:
parent
202c9e91f0
commit
c372a491a7
5 changed files with 21 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
|||
#![cfg(feature = "id3")]
|
||||
|
||||
use crate::tag::ID3Format;
|
||||
use crate::tag::Id3Format;
|
||||
use crate::{
|
||||
impl_tag, Album, AnyTag, AudioTag, AudioTagEdit, AudioTagWrite, Error, MimeType, Picture,
|
||||
Result, TagType, ToAny, ToAnyTag,
|
||||
|
@ -16,26 +16,26 @@ use std::path::Path;
|
|||
#[cfg(feature = "duration")]
|
||||
use std::time::Duration;
|
||||
|
||||
impl_tag!(Id3v2Tag, Id3v2InnerTag, TagType::Id3v2(ID3Format::Default));
|
||||
impl_tag!(Id3v2Tag, Id3v2InnerTag, TagType::Id3v2(Id3Format::Default));
|
||||
|
||||
impl Id3v2Tag {
|
||||
#[allow(clippy::missing_errors_doc)]
|
||||
pub fn read_from_path<P>(path: P, format: ID3Format) -> Result<Self>
|
||||
pub fn read_from_path<P>(path: P, format: Id3Format) -> Result<Self>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
return match format {
|
||||
ID3Format::Default => Ok(Self {
|
||||
Id3Format::Default => Ok(Self {
|
||||
inner: Id3v2InnerTag::read_from_path(&path)?,
|
||||
#[cfg(feature = "duration")]
|
||||
duration: Some(mp3_duration::from_path(&path)?),
|
||||
}),
|
||||
ID3Format::RIFF => Ok(Self {
|
||||
Id3Format::Riff => Ok(Self {
|
||||
inner: Id3v2InnerTag::read_from_wav(&path)?,
|
||||
#[cfg(feature = "duration")]
|
||||
duration: None, // TODO
|
||||
}),
|
||||
ID3Format::Form => Ok(Self {
|
||||
Id3Format::Form => Ok(Self {
|
||||
inner: Id3v2InnerTag::read_from_aiff(&path)?,
|
||||
#[cfg(feature = "duration")]
|
||||
duration: None, // TODO
|
||||
|
|
|
@ -24,7 +24,7 @@ pub enum Error {
|
|||
Id3Tag(#[from] id3::Error),
|
||||
#[cfg(feature = "duration")]
|
||||
#[error(transparent)]
|
||||
MP3Duration(#[from] mp3_duration::MP3DurationError),
|
||||
Mp3Duration(#[from] mp3_duration::MP3DurationError),
|
||||
#[error(transparent)]
|
||||
Mp4Tag(#[from] mp4ameta::Error),
|
||||
#[error(transparent)]
|
||||
|
@ -45,6 +45,7 @@ pub enum Error {
|
|||
FromUtf8(#[from] std::string::FromUtf8Error),
|
||||
/// Represents all cases of `std::io::Error`.
|
||||
#[error(transparent)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
IO(#[from] std::io::Error),
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ pub use crate::types::{
|
|||
};
|
||||
|
||||
mod tag;
|
||||
pub use crate::tag::{ID3Format, Tag, TagType, VorbisFormat};
|
||||
pub use crate::tag::{Id3Format, Tag, TagType, VorbisFormat};
|
||||
|
||||
mod error;
|
||||
pub use crate::error::{Error, Result};
|
||||
|
|
20
src/tag.rs
20
src/tag.rs
|
@ -111,8 +111,8 @@ pub enum TagType {
|
|||
/// Common file extensions: `.ape`
|
||||
Ape,
|
||||
#[cfg(feature = "id3")]
|
||||
/// Represents multiple formats, see [`ID3Format`](ID3Format) for extensions.
|
||||
Id3v2(ID3Format),
|
||||
/// Represents multiple formats, see [`Id3Format`](Id3Format) for extensions.
|
||||
Id3v2(Id3Format),
|
||||
#[cfg(feature = "mp4")]
|
||||
/// Common file extensions: `.mp4, .m4a, .m4p, .m4b, .m4r, .m4v`
|
||||
Mp4,
|
||||
|
@ -143,13 +143,13 @@ pub enum VorbisFormat {
|
|||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg(feature = "id3")]
|
||||
/// ID3 tag's underlying format
|
||||
pub enum ID3Format {
|
||||
pub enum Id3Format {
|
||||
/// MP3
|
||||
Default,
|
||||
/// AIFF
|
||||
Form,
|
||||
/// RIFF/WAV/WAVE
|
||||
RIFF,
|
||||
Riff,
|
||||
}
|
||||
|
||||
impl TagType {
|
||||
|
@ -158,11 +158,11 @@ impl TagType {
|
|||
#[cfg(feature = "ape")]
|
||||
"ape" => Ok(Self::Ape),
|
||||
#[cfg(feature = "id3")]
|
||||
"aiff" | "aif" => Ok(Self::Id3v2(ID3Format::Form)),
|
||||
"aiff" | "aif" => Ok(Self::Id3v2(Id3Format::Form)),
|
||||
#[cfg(feature = "id3")]
|
||||
"mp3" => Ok(Self::Id3v2(ID3Format::Default)),
|
||||
"mp3" => Ok(Self::Id3v2(Id3Format::Default)),
|
||||
#[cfg(all(feature = "riff", feature = "id3"))]
|
||||
"wav" | "wave" | "riff" => Ok(Self::Id3v2(ID3Format::RIFF)),
|
||||
"wav" | "wave" | "riff" => Ok(Self::Id3v2(Id3Format::Riff)),
|
||||
#[cfg(feature = "opus")]
|
||||
"opus" => Ok(Self::Vorbis(VorbisFormat::Opus)),
|
||||
#[cfg(feature = "flac")]
|
||||
|
@ -183,7 +183,7 @@ impl TagType {
|
|||
#[cfg(feature = "ape")]
|
||||
77 if data.starts_with(&MAC) => Ok(Self::Ape),
|
||||
#[cfg(feature = "id3")]
|
||||
73 if data.starts_with(&ID3) => Ok(Self::Id3v2(ID3Format::Default)),
|
||||
73 if data.starts_with(&ID3) => Ok(Self::Id3v2(Id3Format::Default)),
|
||||
#[cfg(feature = "id3")]
|
||||
70 if data.starts_with(&FORM) => {
|
||||
use byteorder::{BigEndian, LittleEndian, ReadBytesExt};
|
||||
|
@ -216,7 +216,7 @@ impl TagType {
|
|||
}
|
||||
|
||||
if found_id3 {
|
||||
return Ok(Self::Id3v2(ID3Format::Form));
|
||||
return Ok(Self::Id3v2(Id3Format::Form));
|
||||
}
|
||||
|
||||
// TODO: support AIFF chunks?
|
||||
|
@ -264,7 +264,7 @@ impl TagType {
|
|||
}
|
||||
|
||||
if found_id3 {
|
||||
return Ok(Self::Id3v2(ID3Format::RIFF));
|
||||
return Ok(Self::Id3v2(Id3Format::Riff));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use lofty::{ID3Format, Tag, TagType, ToAnyTag, VorbisTag};
|
||||
use lofty::{Id3Format, Tag, TagType, ToAnyTag, VorbisTag};
|
||||
|
||||
#[test]
|
||||
#[cfg(all(feature = "id3", feature = "flac"))]
|
||||
|
@ -15,7 +15,7 @@ fn test_inner() {
|
|||
let tag: VorbisTag = innertag.into();
|
||||
|
||||
// Turn the VorbisTag into a Box<dyn AudioTag>
|
||||
let id3tag = tag.to_dyn_tag(TagType::Id3v2(ID3Format::Default));
|
||||
let id3tag = tag.to_dyn_tag(TagType::Id3v2(Id3Format::Default));
|
||||
|
||||
// Write Box<dyn AudioTag> to `a.mp3`
|
||||
id3tag
|
||||
|
|
Loading…
Reference in a new issue