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

Initialize a new tag with a certain TagType

Change the TagType, remapping all items

Returns the TagType

Returns the number of TagItems

Returns the number of Pictures

Returns the stored TagItems as a slice

Returns a reference to a TagItem matching an ItemKey

Get a string value from an ItemKey

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

NOTE: This will verify an ItemKey mapping exists for the target TagType

This will return true if the item was inserted.

Insert a TagItem, replacing any existing one of the same type

Notes:

  • This will not verify an ItemKey mapping 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 stored Pictures as a slice

Returns the first occurrence of the PictureType

Pushes a Picture to the tag

Removes all Pictures of a PictureType

Save the Tag to a path

Errors
  • Path doesn’t exist
  • Path is not writable
  • See Tag::save_to

Save the Tag to a File

Errors

Trait Implementations

Gets the artist

Sets the artist

Removes the artist

Gets the title

Sets the title

Removes the title

Gets the album

Sets the album

Removes the album

Gets the genre

Sets the genre

Removes the genre

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.