pub trait TagExt: Accessor + Into<Tag> + Sized {
    type Err;

    fn is_empty(&self) -> bool;
    fn save_to_path<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Err>;
    fn save_to(&self, file: &mut File) -> Result<(), Self::Err>;
    fn dump_to<W: Write>(&self, writer: &mut W) -> Result<(), Self::Err>;
    fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Err>;
    fn remove_from(&self, file: &mut File) -> Result<(), Self::Err>;
    fn clear(&mut self);
}
Expand description

A set of common methods between tags

This provides a set of methods to make interaction with all tags a similar experience.

This can be implemented downstream to provide a familiar interface for custom tags.

Required Associated Types

The associated error which can be returned from IO operations

Required Methods

Whether the tag has any items

Example
use lofty::{Accessor, Tag, TagExt};

let mut tag = Tag::new(tag_type);
assert!(tag.is_empty());

tag.set_artist(String::from("Foo artist"));
assert!(!tag.is_empty());

Save the tag to a path

Errors

Save the tag to a File

Errors
  • The file format could not be determined
  • Attempting to write a tag to a format that does not support it.

Dump the tag to a writer

This will only write the tag, it will not produce a usable file.

Remove a tag from a Path

Errors

See TagExt::remove_from

Remove a tag from a File

Errors
  • It is unable to guess the file format
  • The format doesn’t support the tag
  • It is unable to write to the file

Clear the tag, removing all items

NOTE: This will not remove any format-specific extras, such as flags

Implementors