pub trait AudioFile: Into<TaggedFile> {
    type Properties;
    // Required methods
    fn read_from<R>(reader: &mut R, parse_options: ParseOptions) -> Result<Self>
       where R: Read + Seek,
             Self: Sized;
    fn save_to<F>(
        &self,
        file: &mut F,
        write_options: WriteOptions,
    ) -> Result<()>
       where F: FileLike,
             LoftyError: From<<F as Truncate>::Error> + From<<F as Length>::Error>;
    fn properties(&self) -> &Self::Properties;
    fn contains_tag(&self) -> bool;
    fn contains_tag_type(&self, tag_type: TagType) -> bool;
    // Provided method
    fn save_to_path(
        &self,
        path: impl AsRef<Path>,
        write_options: WriteOptions,
    ) -> Result<()> { ... }
}Expand description
Provides various methods for interaction with a file
Required Associated Types§
Sourcetype Properties
 
type Properties
The struct the file uses for audio properties
Not all formats can use FileProperties since they may contain additional information
Required Methods§
Sourcefn read_from<R>(reader: &mut R, parse_options: ParseOptions) -> Result<Self>
 
fn read_from<R>(reader: &mut R, parse_options: ParseOptions) -> Result<Self>
Sourcefn save_to<F>(&self, file: &mut F, write_options: WriteOptions) -> Result<()>
 
fn save_to<F>(&self, file: &mut F, write_options: WriteOptions) -> Result<()>
Attempts to write all tags to a file
§Errors
See TagExt::save_to, however this is applicable to every tag in the file.
§Examples
use lofty::config::WriteOptions;
use lofty::file::{AudioFile, TaggedFileExt};
use std::fs::OpenOptions;
let mut tagged_file = lofty::read_from_path(path)?;
// Edit the tags
let mut file = OpenOptions::new().read(true).write(true).open(path)?;
tagged_file.save_to(&mut file, WriteOptions::default())?;Sourcefn properties(&self) -> &Self::Properties
 
fn properties(&self) -> &Self::Properties
Returns a reference to the file’s properties
Sourcefn contains_tag(&self) -> bool
 
fn contains_tag(&self) -> bool
Checks if the file contains any tags
Sourcefn contains_tag_type(&self, tag_type: TagType) -> bool
 
fn contains_tag_type(&self, tag_type: TagType) -> bool
Checks if the file contains the given TagType
Provided Methods§
Sourcefn save_to_path(
    &self,
    path: impl AsRef<Path>,
    write_options: WriteOptions,
) -> Result<()>
 
fn save_to_path( &self, path: impl AsRef<Path>, write_options: WriteOptions, ) -> Result<()>
Attempts to write all tags to a path
§Errors
- pathdoes not exist
- pathis not writable
- See AudioFile::save_to
§Examples
use lofty::config::WriteOptions;
use lofty::file::{AudioFile, TaggedFileExt};
let mut tagged_file = lofty::read_from_path(path)?;
// Edit the tags
tagged_file.save_to_path(path, WriteOptions::default())?;Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.