#[non_exhaustive]
pub enum FileType {
    AAC,
    AIFF,
    APE,
    FLAC,
    MPEG,
    MP4,
    Opus,
    Vorbis,
    Speex,
    WAV,
    WavPack,
    Custom(&'static str),
}
Expand description

The type of file read

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

AAC

AIFF

APE

FLAC

MPEG

MP4

Opus

Vorbis

Speex

WAV

WavPack

Custom(&'static str)

Implementations

Returns the file type’s “primary” TagType, or the one most likely to be used in the target format

FileTypeTagType
AAC, AIFF, MP3, WAVID3v2
APE , WavPackAPE
FLAC, Opus, Vorbis, SpeexVorbisComments
MP4MP4ilst
Panics

If an unregistered FileType (FileType::Custom) is encountered. See register_custom_resolver.

Examples
use lofty::{FileType, TagType};

let file_type = FileType::MPEG;
assert_eq!(file_type.primary_tag_type(), TagType::ID3v2);

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.

Examples
use lofty::{FileType, TagType};

let file_type = FileType::MPEG;
assert!(file_type.supports_tag_type(TagType::ID3v2));

Attempts to extract a FileType from an extension

Examples
use lofty::FileType;

let extension = "mp3";
assert_eq!(FileType::from_ext(extension), Some(FileType::MPEG));

Attempts to determine a FileType from a path

Examples
use lofty::FileType;
use std::path::Path;

let path = Path::new("path/to/my.mp3");
assert_eq!(FileType::from_path(path), Some(FileType::MPEG));

Attempts to extract a FileType from a buffer

NOTES:

Examples
use lofty::FileType;
use std::fs::File;
use std::io::Read;

let mut file = File::open(path_to_opus)?;

let mut buf = [0; 50]; // Search the first 50 bytes of the file
file.read_exact(&mut buf)?;

assert_eq!(FileType::from_buffer(&buf), Some(FileType::Opus));

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.