FileType: Remove feature dependent returns

This commit is contained in:
Serial 2022-09-29 18:20:57 -04:00
parent 8b8f355d89
commit ac420960de
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
2 changed files with 11 additions and 17 deletions

View file

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **ID3v2**: Frame/tag flags with optional additional data are now `Option<T>` instead of `(bool, T)`
- `read_from{_path}` will no longer take a `bool` for reading properties, and will do it by default. To
change this behavior, you must now use `Probe`.
- **FileType**: `primary_tag_type` will no longer change its return depending on the enabled features.
## Removed
- **lofty_attr**: The `#[lofty(always_present)]` attribute has been removed, and is now inferred.

View file

@ -496,15 +496,14 @@ pub enum FileType {
}
impl FileType {
#[allow(unreachable_patterns, clippy::match_same_arms)]
/// Returns the file type's "primary" [`TagType`], or the one most likely to be used in the target format
///
/// | [`FileType`] | [`TagType`] |
/// |--------------------------|------------------|
/// | `AIFF`, `MP3`, `WAV` | `Id3v2` |
/// | `APE` , `WavPack` | `Ape` |
/// | `FLAC`, `Opus`, `Vorbis` | `VorbisComments` |
/// | `MP4` | `Mp4Ilst` |
/// | [`FileType`] | [`TagType`] |
/// |-----------------------------------|------------------|
/// | `AIFF`, `MP3`, `WAV` | `ID3v2` |
/// | `APE` , `WavPack` | `APE` |
/// | `FLAC`, `Opus`, `Vorbis`, `Speex` | `VorbisComments` |
/// | `MP4` | `MP4ilst` |
///
/// # Panics
///
@ -520,17 +519,7 @@ impl FileType {
/// ```
pub fn primary_tag_type(&self) -> TagType {
match self {
#[cfg(all(not(feature = "id3v2"), feature = "aiff_text_chunks"))]
FileType::AIFF => TagType::AIFFText,
#[cfg(all(not(feature = "id3v2"), feature = "riff_info_list"))]
FileType::WAV => TagType::RIFFInfo,
#[cfg(all(not(feature = "id3v2"), feature = "id3v1"))]
FileType::MPEG => TagType::ID3v1,
#[cfg(all(not(feature = "id3v2"), not(feature = "id3v1"), feature = "ape"))]
FileType::MPEG => TagType::APE,
FileType::AIFF | FileType::MPEG | FileType::WAV => TagType::ID3v2,
#[cfg(all(not(feature = "ape"), feature = "id3v1"))]
FileType::MPEG | FileType::WavPack => TagType::ID3v1,
FileType::APE | FileType::WavPack => TagType::APE,
FileType::FLAC | FileType::Opus | FileType::Vorbis | FileType::Speex => {
TagType::VorbisComments
@ -551,6 +540,10 @@ impl FileType {
/// Returns if the target `FileType` supports a [`TagType`]
///
/// NOTE: This is feature dependent, meaning if you do not have the
/// `id3v2` feature enabled, [`FileType::MPEG`] will return `false` for
/// [`TagType::ID3v2`].
///
/// # Panics
///
/// If an unregistered `FileType` ([`FileType::Custom`]) is encountered. See [`register_custom_resolver`](crate::resolve::register_custom_resolver).