#[non_exhaustive]pub enum FileType {
Show 13 variants
Aac,
Aiff,
Ape,
Flac,
Mpeg,
Mp4,
Mpc,
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.
Implementations§
source§impl 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 , Mpc , 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§
source§impl PartialEq for FileType
impl PartialEq for FileType
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more