Struct id3::Tag [] [src]

pub struct Tag { /* fields omitted */ }

An ID3 tag containing metadata frames.

Methods

impl<'a> Tag
[src]

[src]

Creates a new ID3v2.4 tag with no frames.

[src]

Deprecated

: Tags now use ID3v2.4 for internal storage

Creates a new ID3 tag with the specified version.

[src]

Deprecated

: Use v1::Tag::is_candidate

Returns true if the reader might contain a valid ID3v1 tag.

[src]

Deprecated

: Use tag_v1.into()

Attempts to read an ID3v1 tag from the reader. Since the structure of ID3v1 is so different from ID3v2, the tag will be converted and stored internally as an ID3v2.3 tag.

[src]

Deprecated

: Use tag_v1.into()

Attempts to read an ID3v1 tag from the file at the specified path. The tag will be converted into an ID3v2.3 tag upon success.

[src]

Deprecated

: Tags now use ID3v2.4 for internal storage

Returns the version of the tag.

[src]

Deprecated

: Tags now use ID3v2.4 for internal storage

Sets the version of this tag.

[src]

Returns an iterator over the all frames in the tag.

Example

use id3::{Tag, Frame, Content};

let mut tag = Tag::new();

tag.add_frame(Frame::with_content("TPE1", Content::Text("".to_string())));
tag.add_frame(Frame::with_content("APIC", Content::Text("".to_string())));

assert_eq!(tag.frames().count(), 2);

[src]

Returns an iterator over the extended texts in the tag.

Returns an iterator over the extended links in the tag.

[src]

Returns an iterator over the comments in the tag.

Example

use id3::{Tag, Frame};
use id3::frame::{Content, Comment};

let mut tag = Tag::new();

let frame = Frame::with_content("COMM", Content::Comment(Comment {
    lang: "eng".to_owned(),
    description: "key1".to_owned(),
    text: "value1".to_owned()
}));
tag.add_frame(frame);

let frame = Frame::with_content("COMM", Content::Comment(Comment {
    lang: "eng".to_owned(),
    description: "key2".to_owned(),
    text: "value2".to_owned()
}));
tag.add_frame(frame);

assert_eq!(tag.comments().count(), 2);

[src]

Returns an iterator over the extended links in the tag.

[src]

Returns an iterator over the pictures in the tag.

Example

use id3::{Tag, Frame};
use id3::frame::{Content, Picture, PictureType};

let mut tag = Tag::new();

let picture = Picture {
    mime_type: String::new(),
    picture_type: PictureType::Other,
    description: String::new(),
    data: Vec::new(),
};
tag.add_frame(Frame::with_content("APIC", Content::Picture(picture.clone())));
tag.add_frame(Frame::with_content("APIC", Content::Picture(picture.clone())));

assert_eq!(tag.pictures().count(), 1);

[src]

Returns a reference to the first frame with the specified identifier.

Example

use id3::{Tag, Frame, Content};

let mut tag = Tag::new();

tag.add_frame(Frame::with_content("TIT2", Content::Text("".to_string())));

assert!(tag.get("TIT2").is_some());
assert!(tag.get("TCON").is_none());

[src]

Deprecated

: Combine frames() with Iterator::filter

Returns a vector of references to frames with the specified identifier.

Example

use id3::{Tag, Frame, Content};

let mut tag = Tag::new();

tag.add_frame(Frame::with_content("TPE1", Content::Text("".to_string())));
tag.add_frame(Frame::with_content("TALB", Content::Text("".to_string())));

assert_eq!(tag.get_all("TPE1").len(), 1);
assert_eq!(tag.get_all("TALB").len(), 1);

[src]

Deprecated

: Use add_frame

Adds the frame to the tag. The frame identifier will attempt to be converted into the corresponding identifier for the tag version.

Returns whether the frame was added to the tag. The only reason the frame would not be added to the tag is if the frame identifier could not be converted from the frame version to the tag version.

Example

use id3::{Tag, Frame, Content};

let mut tag = Tag::new();
tag.push(Frame::with_content("TALB", Content::Text("".to_string())));
assert_eq!(tag.frames().nth(0).unwrap().id(), "TALB");

[src]

Adds the frame to the tag, replacing and returning any conflicting frame.

Example

use id3::{Tag, Frame, Content};

let mut tag = Tag::new();
tag.add_frame(Frame::with_content("TALB", Content::Text("".to_string())));
tag.add_frame(Frame::with_content("TALB", Content::Text("".to_string())));
assert_eq!(tag.frames().nth(0).unwrap().id(), "TALB");

[src]

Deprecated

: Use set_text()

Adds a text frame.

Example

use id3::Tag;

let mut tag = Tag::new();
tag.add_text_frame("TRCK", "1/13");
assert_eq!(tag.get("TRCK").unwrap().content().text().unwrap(), "1/13");

[src]

Adds a text frame.

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_text("TRCK", "1/13");
assert_eq!(tag.get("TRCK").unwrap().content().text().unwrap(), "1/13");

[src]

Removes all frames with the specified identifier.

Example

use id3::{Tag, Frame, Content};

let mut tag = Tag::new();

tag.add_frame(Frame::with_content("TALB", Content::Text("".to_string())));
tag.add_frame(Frame::with_content("TPE1", Content::Text("".to_string())));

assert_eq!(tag.frames().count(), 2);

tag.remove("TALB");
assert_eq!(tag.frames().count(), 1);

tag.remove("TPE1");
assert_eq!(tag.frames().count(), 0);

[src]

Deprecated

: Use extended_texts()

Returns a vector of the extended text (TXXX) description/value pairs.

[src]

Adds a user defined text frame (TXXX).

Example

use id3::Tag;

let mut tag = Tag::new();

tag.add_extended_text("key1", "value1");
tag.add_extended_text("key2", "value2");

assert_eq!(tag.extended_texts().count(), 2);
assert!(tag.extended_texts().any(|t| t.description == "key1" && t.value == "value1"));
assert!(tag.extended_texts().any(|t| t.description == "key2" && t.value == "value2"));

[src]

Deprecated

: Use add_extended_text()

Adds a user defined text frame (TXXX).

[src]

Removes the user defined text frame (TXXX) with the specified key and value.

A key or value may be None to specify a wildcard value.

Example

use id3::Tag;

let mut tag = Tag::new();

tag.add_extended_text("key1", "value1");
tag.add_extended_text("key2", "value2");
tag.add_extended_text("key3", "value2");
tag.add_extended_text("key4", "value3");
tag.add_extended_text("key5", "value4");
assert_eq!(tag.extended_texts().count(), 5);

tag.remove_extended_text(Some("key1"), None);
assert_eq!(tag.extended_texts().count(), 4);

tag.remove_extended_text(None, Some("value2"));
assert_eq!(tag.extended_texts().count(), 2);

tag.remove_extended_text(Some("key4"), Some("value3"));
assert_eq!(tag.extended_texts().count(), 1);

tag.remove_extended_text(None, None);
assert_eq!(tag.extended_texts().count(), 0);

[src]

Deprecated

: Use remove_extended_text()

Removes the user defined text frame (TXXX) with the specified key and value.

A key or value may be None to specify a wildcard value.

[src]

Adds a picture frame (APIC). Any other pictures with the same type will be removed from the tag.

Example

use id3::Tag;
use id3::frame::{Picture, PictureType};

let mut tag = Tag::new();
tag.add_picture(Picture {
    mime_type: "image/jpeg".to_string(),
    picture_type: PictureType::Other,
    description: "some image".to_string(),
    data: vec![],
});
tag.add_picture(Picture {
    mime_type: "image/png".to_string(),
    picture_type: PictureType::Other,
    description: "some other image".to_string(),
    data: vec![],
});
assert_eq!(tag.pictures().count(), 1);
assert_eq!(&tag.pictures().nth(0).unwrap().mime_type[..], "image/png");

[src]

Removes all pictures of the specified type.

Example

use id3::Tag;
use id3::frame::{Picture, PictureType};

let mut tag = Tag::new();
tag.add_picture(Picture {
    mime_type: "image/jpeg".to_string(),
    picture_type: PictureType::Other,
    description: "some image".to_string(),
    data: vec![],
});
tag.add_picture(Picture {
    mime_type: "image/png".to_string(),
    picture_type: PictureType::CoverFront,
    description: "some other image".to_string(),
    data: vec![],
});

assert_eq!(tag.pictures().count(), 2);
tag.remove_picture_by_type(PictureType::CoverFront);
assert_eq!(tag.pictures().count(), 1);
assert_eq!(tag.pictures().nth(0).unwrap().picture_type, PictureType::Other);

[src]

Adds a comment (COMM).

Example

use id3::Tag;
use id3::frame::Comment;

let mut tag = Tag::new();

let com1 = Comment {
    lang: "eng".to_string(),
    description: "key1".to_string(),
    text: "value1".to_string(),
};
let com2 = Comment {
    lang: "eng".to_string(),
    description: "key2".to_string(),
    text: "value2".to_string(),
};
tag.add_comment(com1.clone());
tag.add_comment(com2.clone());

assert_eq!(tag.comments().count(), 2);
assert_ne!(None, tag.comments().position(|c| *c == com1));
assert_ne!(None, tag.comments().position(|c| *c == com2));

[src]

Removes the comment (COMM) with the specified key and value.

A key or value may be None to specify a wildcard value.

Example

use id3::Tag;
use id3::frame::Comment;

let mut tag = Tag::new();

tag.add_comment(Comment {
    lang: "eng".to_string(),
    description: "key1".to_string(),
    text: "value1".to_string(),
});
tag.add_comment(Comment {
    lang: "eng".to_string(),
    description: "key2".to_string(),
    text: "value2".to_string(),
});
assert_eq!(tag.comments().count(), 2);

tag.remove_comment(Some("key1"), None);
assert_eq!(tag.comments().count(), 1);

tag.remove_comment(None, Some("value2"));
assert_eq!(tag.comments().count(), 0);

[src]

Returns the year (TYER). Returns None if the year frame could not be found or if it could not be parsed.

Example

use id3::{Tag, Frame};
use id3::frame::Content;

let mut tag = Tag::new();
assert!(tag.year().is_none());

let frame_valid = Frame::with_content("TYER", Content::Text("2014".to_owned()));
tag.add_frame(frame_valid);
assert_eq!(tag.year().unwrap(), 2014);

tag.remove("TYER");

let frame_invalid = Frame::with_content("TYER", Content::Text("nope".to_owned()));
tag.add_frame(frame_invalid);
assert!(tag.year().is_none());

[src]

Sets the year (TYER).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_year(2014);
assert_eq!(tag.year().unwrap(), 2014);

[src]

Return the content of the TRDC frame, if any

Example

use id3::Tag;
use id3::Timestamp;

let mut tag = Tag::new();
tag.set_date_recorded(Timestamp{ year: 2014, month: None, day: None, hour: None, minute: None, second: None });
assert_eq!(tag.date_recorded().unwrap().year, 2014);

[src]

Sets the content of the TDRC frame

Example

use id3::Tag;
use id3::Timestamp;

let mut tag = Tag::new();
tag.set_date_recorded(Timestamp{ year: 2014, month: None, day: None, hour: None, minute: None, second: None });
assert_eq!(tag.date_recorded().unwrap().year, 2014);

[src]

Return the content of the TDRL frame, if any

Example

use id3::Tag;
use id3::Timestamp;

let mut tag = Tag::new();
tag.set_date_released(Timestamp{ year: 2014, month: None, day: None, hour: None, minute: None, second: None });
assert_eq!(tag.date_released().unwrap().year, 2014);

[src]

Sets the content of the TDRL frame

Example

use id3::Tag;
use id3::Timestamp;

let mut tag = Tag::new();
tag.set_date_released(Timestamp{ year: 2014, month: None, day: None, hour: None, minute: None, second: None });
assert_eq!(tag.date_released().unwrap().year, 2014);

[src]

Returns the artist (TPE1).

Example

use id3::{Frame, Tag};
use id3::frame::Content;

let mut tag = Tag::new();
let frame = Frame::with_content("TPE1", Content::Text("artist".to_owned()));
tag.add_frame(frame);
assert_eq!(tag.artist().unwrap(), "artist");

[src]

Sets the artist (TPE1).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_artist("artist");
assert_eq!(tag.artist().unwrap(), "artist");

[src]

Removes the artist (TPE1).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_artist("artist");
assert!(tag.artist().is_some());

tag.remove_artist();
assert!(tag.artist().is_none());

[src]

Sets the album artist (TPE2).

Example

use id3::{Frame, Tag};
use id3::frame::Content;

let mut tag = Tag::new();
let frame = Frame::with_content("TPE2", Content::Text("artist".to_owned()));
tag.add_frame(frame);
assert_eq!(tag.album_artist().unwrap(), "artist");

[src]

Sets the album artist (TPE2).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_album_artist("artist");
assert_eq!(tag.album_artist().unwrap(), "artist");

[src]

Removes the album artist (TPE2).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_album_artist("artist");
assert!(tag.album_artist().is_some());

tag.remove_album_artist();
assert!(tag.album_artist().is_none());

[src]

Returns the album (TALB).

Example

use id3::{Frame, Tag};
use id3::frame::Content;

let mut tag = Tag::new();
let frame = Frame::with_content("TALB", Content::Text("album".to_owned()));
tag.add_frame(frame);
assert_eq!(tag.album().unwrap(), "album");

[src]

Sets the album (TALB).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_album("album");
assert_eq!(tag.album().unwrap(), "album");

[src]

Removes the album (TALB).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_album("album");
assert!(tag.album().is_some());

tag.remove_album();
assert!(tag.album().is_none());

[src]

Returns the title (TIT2).

Example

use id3::{Frame, Tag};
use id3::frame::Content;

let mut tag = Tag::new();
let frame = Frame::with_content("TIT2", Content::Text("title".to_owned()));
tag.add_frame(frame);
assert_eq!(tag.title().unwrap(), "title");

[src]

Sets the title (TIT2).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_title("title");
assert_eq!(tag.title().unwrap(), "title");

[src]

Removes the title (TIT2).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_title("title");
assert!(tag.title().is_some());

tag.remove_title();
assert!(tag.title().is_none());

[src]

Returns the duration (TLEN).

Example

use id3::{Frame, Tag};
use id3::frame::Content;

let mut tag = Tag::new();

let frame = Frame::with_content("TLEN", Content::Text("350".to_owned()));
tag.add_frame(frame);
assert_eq!(tag.duration().unwrap(), 350);

[src]

Sets the duration (TLEN).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_duration(350);
assert_eq!(tag.duration().unwrap(), 350);

[src]

Removes the duration (TLEN).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_duration(350);
assert!(tag.duration().is_some());

tag.remove_duration();
assert!(tag.duration().is_none());

[src]

Returns the genre (TCON).

Example

use id3::{Frame, Tag};
use id3::frame::Content;

let mut tag = Tag::new();
let frame = Frame::with_content("TCON", Content::Text("genre".to_owned()));
tag.add_frame(frame);
assert_eq!(tag.genre().unwrap(), "genre");

[src]

Sets the genre (TCON).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_genre("genre");
assert_eq!(tag.genre().unwrap(), "genre");

[src]

Removes the genre (TCON).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_genre("genre");
assert!(tag.genre().is_some());

tag.remove_genre();
assert!(tag.genre().is_none());

[src]

Returns the disc number (TPOS).

Example

use id3::{Tag, Frame};
use id3::frame::Content;

let mut tag = Tag::new();
assert!(tag.disc().is_none());

let mut frame_valid = Frame::with_content("TPOS", Content::Text("4".to_owned()));
tag.add_frame(frame_valid);
assert_eq!(tag.disc().unwrap(), 4);

tag.remove("TPOS");

let mut frame_invalid = Frame::with_content("TPOS", Content::Text("nope".to_owned()));
tag.add_frame(frame_invalid);
assert!(tag.disc().is_none());

[src]

Sets the disc (TPOS).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_disc(2);
assert_eq!(tag.disc().unwrap(), 2);

[src]

Removes the disc number (TPOS).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_disc(3);
assert!(tag.disc().is_some());

tag.remove_disc();
assert!(tag.disc().is_none());

[src]

Returns the total number of discs (TPOS).

Example

use id3::{Tag, Frame};
use id3::frame::Content;

let mut tag = Tag::new();
assert!(tag.disc().is_none());

let frame_valid = Frame::with_content("TPOS", Content::Text("4/10".to_owned()));
tag.add_frame(frame_valid);
assert_eq!(tag.total_discs().unwrap(), 10);

tag.remove("TPOS");

let frame_invalid = Frame::with_content("TPOS", Content::Text("4/nope".to_owned()));
tag.add_frame(frame_invalid);
assert!(tag.total_discs().is_none());

[src]

Sets the total number of discs (TPOS).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_total_discs(10);
assert_eq!(tag.total_discs().unwrap(), 10);

[src]

Removes the total number of discs (TPOS).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_total_discs(10);
assert!(tag.total_discs().is_some());

tag.remove_total_discs();
assert!(tag.total_discs().is_none());

[src]

Returns the track number (TRCK).

Example

use id3::{Tag, Frame};
use id3::frame::Content;

let mut tag = Tag::new();
assert!(tag.track().is_none());

let frame_valid = Frame::with_content("TRCK", Content::Text("4".to_owned()));
tag.add_frame(frame_valid);
assert_eq!(tag.track().unwrap(), 4);

tag.remove("TRCK");

let frame_invalid = Frame::with_content("TRCK", Content::Text("nope".to_owned()));
tag.add_frame(frame_invalid);
assert!(tag.track().is_none());

[src]

Sets the track (TRCK).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_track(10);
assert_eq!(tag.track().unwrap(), 10);

[src]

Removes the track number (TRCK).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_track(10);
assert!(tag.track().is_some());

tag.remove_track();
assert!(tag.track().is_none());

[src]

Returns the total number of tracks (TRCK).

Example

use id3::{Tag, Frame};
use id3::frame::Content;

let mut tag = Tag::new();
assert!(tag.total_tracks().is_none());

let frame_valid = Frame::with_content("TRCK", Content::Text("4/10".to_owned()));
tag.add_frame(frame_valid);
assert_eq!(tag.total_tracks().unwrap(), 10);

tag.remove("TRCK");

let frame_invalid = Frame::with_content("TRCK", Content::Text("4/nope".to_owned()));
tag.add_frame(frame_invalid);
assert!(tag.total_tracks().is_none());

[src]

Sets the total number of tracks (TRCK).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_total_tracks(10);
assert_eq!(tag.total_tracks().unwrap(), 10);

[src]

Removes the total number of tracks (TCON).

Example

use id3::Tag;

let mut tag = Tag::new();
tag.set_total_tracks(10);
assert!(tag.total_tracks().is_some());

tag.remove_total_tracks();
assert!(tag.total_tracks().is_none());

[src]

Deprecated

: There can be more than one lyrics frame

Sets the lyrics (USLT).

Example

use id3::Tag;
use id3::frame::Lyrics;

let mut tag = Tag::new();
tag.set_lyrics(Lyrics {
    lang: "eng".to_string(),
    description: "".to_string(),
    text: "The lyrics".to_string(),
});
assert_eq!(tag.lyrics().nth(0).unwrap().text, "The lyrics");

[src]

Deprecated

: There can be more than one lyrics frame

Removes the lyrics text (USLT) from the tag.

Exmaple

use id3::Tag;
use id3::frame::Lyrics;

let mut tag = Tag::new();
tag.set_lyrics(Lyrics {
    lang: "eng".to_string(),
    description: "".to_string(),
    text: "The lyrics".to_string(),
});
assert_eq!(1, tag.lyrics().count());
tag.remove_lyrics();
assert_eq!(0, tag.lyrics().count());

[src]

Deprecated

: Use Tag::skip() instead

Returns the contents of the reader without any ID3 metadata.

[src]

Will return true if the reader is a candidate for an ID3 tag. The reader position will be reset back to the previous position before returning.

[src]

Detects the presense of an ID3v2 tag at the current position of the reader and skips it if it if found. Returns true if a tag was found.

[src]

Attempts to read an ID3 tag from the reader.

[src]

Attempts to read an ID3 tag from the file at the indicated path.

[src]

Attempts to write the ID3 tag to the writer using the specified version.

[src]

Attempts to write the ID3 tag from the file at the indicated path. If the specified path is the same path which the tag was read from, then the tag will be written to the padding if possible.

[src]

Removes an ID3v2 tag from the specified file.

Returns true if the file initially contained a tag.

Trait Implementations

impl Clone for Tag
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Tag
[src]

[src]

Formats the value using the given formatter.

impl Default for Tag
[src]

[src]

Returns the "default value" for a type. Read more

impl Eq for Tag
[src]

impl PartialEq for Tag
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl From<Tag> for Tag
[src]

[src]

Performs the conversion.