pub trait TagExt: Accessor + Into<Tag> + Sized {
type Err: From<Error>;
type RefKey<'a>
where Self: 'a;
// Required methods
fn len(&self) -> usize;
fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool;
fn is_empty(&self) -> bool;
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);
// Provided method
fn save_to_path<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Err> { ... }
}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§
Required Methods§
sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the number of items in the tag
This will also include any extras, such as pictures.
Example
use lofty::{Accessor, ItemKey, Tag, TagExt};
let mut tag = Tag::new(tag_type);
assert_eq!(tag.len(), 0);
tag.set_artist(String::from("Foo artist"));
assert_eq!(tag.len(), 1);sourcefn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool
fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool
Whether the tag contains an item with the key
Example
use lofty::{Accessor, ItemKey, Tag, TagExt};
let mut tag = Tag::new(tag_type);
assert!(tag.is_empty());
tag.set_artist(String::from("Foo artist"));
assert!(tag.contains(&ItemKey::TrackArtist));sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
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());sourcefn dump_to<W: Write>(&self, writer: &mut W) -> Result<(), Self::Err>
fn dump_to<W: Write>(&self, writer: &mut W) -> Result<(), Self::Err>
Dump the tag to a writer
This will only write the tag, it will not produce a usable file.
Provided Methods§
Object Safety§
This trait is not object safe.