#[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
sourceimpl FileType
impl FileType
sourcepub fn primary_tag_type(&self) -> TagType
pub fn primary_tag_type(&self) -> TagType
Returns the file type’s “primary” TagType, or the one most likely to be used in the target format
FileType | TagType |
|---|---|
AAC, AIFF, MP3, WAV | ID3v2 |
APE , WavPack | APE |
FLAC, Opus, Vorbis, Speex | VorbisComments |
MP4 | MP4ilst |
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);sourcepub fn supports_tag_type(&self, tag_type: TagType) -> bool
pub fn supports_tag_type(&self, tag_type: TagType) -> bool
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));sourcepub fn from_buffer(buf: &[u8]) -> Option<Self>
pub fn from_buffer(buf: &[u8]) -> Option<Self>
Attempts to extract a FileType from a buffer
NOTES:
- This is for use in
Probe::guess_file_type, it is recommended to use it that way - This will not search past tags at the start of the buffer.
For this behavior, use
Probe::guess_file_type.
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
impl Copy for FileType
impl Eq for FileType
impl StructuralEq for FileType
impl StructuralPartialEq for FileType
Auto Trait Implementations
impl RefUnwindSafe for FileType
impl Send for FileType
impl Sync for FileType
impl Unpin for FileType
impl UnwindSafe for FileType
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more