rename some cargo features
This commit is contained in:
parent
482dc39fce
commit
8b70b2b851
10
Cargo.toml
10
Cargo.toml
|
@ -51,10 +51,10 @@ tempfile = "3"
|
||||||
notify = "6"
|
notify = "6"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["taglib", "flac", "mp3", "ffmpeg_fallback"]
|
default = ["taglib_extractor", "flac_extractor", "mp3_extractor", "ffmpeg_extractor"]
|
||||||
|
|
||||||
# Formats
|
# Formats
|
||||||
taglib = ["dep:taglib"]
|
taglib_extractor = ["dep:taglib"]
|
||||||
flac = ["dep:metaflac"]
|
flac_extractor = ["dep:metaflac"]
|
||||||
mp3 = ["dep:id3"]
|
mp3_extractor = ["dep:id3"]
|
||||||
ffmpeg_fallback = [] # If to allow using ffmpeg as a fallback tag extractor
|
ffmpeg_extractor = [] # If to allow using ffmpeg as a fallback tag extractor
|
|
@ -1,8 +1,8 @@
|
||||||
#[cfg(feature = "ffmpeg_fallback")]
|
#[cfg(feature = "ffmpeg_extractor")]
|
||||||
pub mod generic_ffmpeg;
|
pub mod generic_ffmpeg;
|
||||||
#[cfg(feature = "flac")]
|
#[cfg(feature = "flac_extractor")]
|
||||||
pub mod flac;
|
pub mod flac;
|
||||||
#[cfg(feature = "taglib")]
|
#[cfg(feature = "taglib_extractor")]
|
||||||
pub mod generic_taglib;
|
pub mod generic_taglib;
|
||||||
#[cfg(feature = "mp3")]
|
#[cfg(feature = "mp3_extractor")]
|
||||||
pub mod id3;
|
pub mod id3;
|
|
@ -7,13 +7,13 @@ use thiserror::Error;
|
||||||
|
|
||||||
use crate::types::{AudioFileInfo, File, ReplayGainRawData, Tags};
|
use crate::types::{AudioFileInfo, File, ReplayGainRawData, Tags};
|
||||||
|
|
||||||
#[cfg(feature = "flac")]
|
#[cfg(feature = "flac_extractor")]
|
||||||
use self::handlers::flac::new_flac_format_handler;
|
use self::handlers::flac::new_flac_format_handler;
|
||||||
#[cfg(feature = "taglib")]
|
#[cfg(feature = "taglib_extractor")]
|
||||||
use self::handlers::generic_taglib::new_taglib_format_handler;
|
use self::handlers::generic_taglib::new_taglib_format_handler;
|
||||||
#[cfg(feature = "mp3")]
|
#[cfg(feature = "mp3_extractor")]
|
||||||
use self::handlers::id3::new_id3_format_handler;
|
use self::handlers::id3::new_id3_format_handler;
|
||||||
#[cfg(feature = "ffmpeg_fallback")]
|
#[cfg(feature = "ffmpeg_extractor")]
|
||||||
use self::handlers::generic_ffmpeg::new_generic_ffmpeg_format_handler;
|
use self::handlers::generic_ffmpeg::new_generic_ffmpeg_format_handler;
|
||||||
|
|
||||||
use super::format_detection::{detect_format, FileFormat};
|
use super::format_detection::{detect_format, FileFormat};
|
||||||
|
@ -49,7 +49,7 @@ pub fn get_format_handler(file: &File) -> Result<Box<dyn AudioContainerFormat>,
|
||||||
let format = detect_format(&file.join_path_to())?;
|
let format = detect_format(&file.join_path_to())?;
|
||||||
let path = file.join_path_to();
|
let path = file.join_path_to();
|
||||||
|
|
||||||
#[cfg(feature = "taglib")]
|
#[cfg(feature = "taglib_extractor")]
|
||||||
{
|
{
|
||||||
match format {
|
match format {
|
||||||
FileFormat::OggFLAC
|
FileFormat::OggFLAC
|
||||||
|
@ -65,19 +65,19 @@ pub fn get_format_handler(file: &File) -> Result<Box<dyn AudioContainerFormat>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "mp3")]
|
#[cfg(feature = "mp3_extractor")]
|
||||||
if format == FileFormat::MP3 {
|
if format == FileFormat::MP3 {
|
||||||
// Native MP3 support
|
// Native MP3 support
|
||||||
return Ok(Box::new(new_id3_format_handler(&path)?));
|
return Ok(Box::new(new_id3_format_handler(&path)?));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "flac")]
|
#[cfg(feature = "flac_extractor")]
|
||||||
if format == FileFormat::FLAC {
|
if format == FileFormat::FLAC {
|
||||||
// Native FLAC support
|
// Native FLAC support
|
||||||
return Ok(Box::new(new_flac_format_handler(&path)?));
|
return Ok(Box::new(new_flac_format_handler(&path)?));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ffmpeg_fallback")]
|
#[cfg(feature = "ffmpeg_extractor")]
|
||||||
match format {
|
match format {
|
||||||
FileFormat::MP3
|
FileFormat::MP3
|
||||||
| FileFormat::FLAC
|
| FileFormat::FLAC
|
||||||
|
@ -99,23 +99,23 @@ pub fn get_format_handler(file: &File) -> Result<Box<dyn AudioContainerFormat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_supported_extension(ext: &str) -> bool {
|
fn is_supported_extension(ext: &str) -> bool {
|
||||||
#[cfg(feature = "taglib")]
|
#[cfg(feature = "taglib_extractor")]
|
||||||
if matches!(ext, "ogg" | "opus" | "wav" | "wv" | "aiff") {
|
if matches!(ext, "ogg" | "opus" | "wav" | "wv" | "aiff") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "mp3")]
|
#[cfg(feature = "mp3_extractor")]
|
||||||
if ext == "mp3" {
|
if ext == "mp3" {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "flac")]
|
#[cfg(feature = "flac_extractor")]
|
||||||
if ext == "flac" {
|
if ext == "flac" {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FFMpeg Fallback
|
// FFMpeg Fallback
|
||||||
#[cfg(feature = "ffmpeg_fallback")]
|
#[cfg(feature = "ffmpeg_extractor")]
|
||||||
if matches!(ext, "mp3" | "flac" | "ogg" | "opus" | "wav" | "wv" | "aiff") {
|
if matches!(ext, "mp3" | "flac" | "ogg" | "opus" | "wav" | "wv" | "aiff") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ pub fn is_supported_file(file_path: &Path) -> bool {
|
||||||
|
|
||||||
let format = format.unwrap();
|
let format = format.unwrap();
|
||||||
|
|
||||||
#[cfg(feature = "taglib")]
|
#[cfg(feature = "taglib_extractor")]
|
||||||
match format {
|
match format {
|
||||||
FileFormat::OggVorbis
|
FileFormat::OggVorbis
|
||||||
| FileFormat::OggOpus
|
| FileFormat::OggOpus
|
||||||
|
@ -157,17 +157,17 @@ pub fn is_supported_file(file_path: &Path) -> bool {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "mp3")]
|
#[cfg(feature = "mp3_extractor")]
|
||||||
if format == FileFormat::MP3 {
|
if format == FileFormat::MP3 {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "flac")]
|
#[cfg(feature = "flac_extractor")]
|
||||||
if format == FileFormat::FLAC {
|
if format == FileFormat::FLAC {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ffmpeg_fallback")]
|
#[cfg(feature = "ffmpeg_extractor")]
|
||||||
match format {
|
match format {
|
||||||
FileFormat::MP3
|
FileFormat::MP3
|
||||||
| FileFormat::FLAC
|
| FileFormat::FLAC
|
||||||
|
|
Loading…
Reference in a new issue