Struct lofty::Tag [−][src]
pub struct Tag { /* fields omitted */ }Expand description
Represents a parsed tag
This is a tag that is loosely bound to a specific TagType.
It is used for conversions and as the return type for read_from.
Compared to other formats, this gives a much higher-level view of the
tag items. Rather than storing items according to their format-specific
keys, ItemKeys are used.
You can easily remap this to another TagType with Tag::re_map.
Any conversion will, of course, be lossy to a varying degree.
Usage
Accessing common items
// There are multiple quick getter methods for common items
let title = tag.title();
let artist = tag.artist();
let album = tag.album();
let genre = tag.genre();Getting an item of a known type
use lofty::ItemKey;
// If the type of an item is known, there are getter methods
// to prevent having to match against the value
tag.get_string(&ItemKey::TrackTitle);
tag.get_binary(&ItemKey::TrackTitle, false);Converting between formats
use lofty::{Tag, TagType};
use lofty::id3::v2::Id3v2Tag;
// Converting between formats is as simple as an `into` call.
// However, such conversions can potentially be *very* lossy.
let tag = Tag::new(TagType::Id3v2);
let id3v2_tag: Id3v2Tag = tag.into();Implementations
Returns the number of TagItems
Returns the number of Pictures
Gets a byte slice from an ItemKey
Use convert to convert ItemValue::Text and ItemValue::Locator to byte slices
Insert a TagItem, replacing any existing one of the same type
Notes:
- This will not verify an
ItemKeymapping exists - This will not allow writing item keys that are out of spec (keys are verified before writing)
This is only necessary if dealing with ItemKey::Unknown.
An alias for Tag::insert_item that doesn’t require the user to create a TagItem
Remove an item by its key
This will remove all items with this key.
Retain tag items based on the predicate
See Vec::retain
Returns the first occurrence of the PictureType
Pushes a Picture to the tag
Removes all Pictures of a PictureType
Save the Tag to a File
Errors
- A
FileTypecouldn’t be determined from the File - Attempting to write a tag to a format that does not support it. See
FileType::supports_tag_type
Same as TagType::remove_from_path
Same as TagType::remove_from
Trait Implementations
Sets the artist
Removes the artist
Removes the title
Removes the album
Removes the genre
Performs the conversion.
Performs the conversion.
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for Tag
impl UnwindSafe for Tag
Blanket Implementations
Mutably borrows from an owned value. Read more
