pub struct Tag { /* private fields */ }
Expand description
An ID3 tag containing zero or more Frame
s.
Implementations
sourceimpl<'a> Tag
impl<'a> Tag
sourcepub fn with_version(version: Version) -> Tag
pub fn with_version(version: Version) -> Tag
Used for creating new tag with a specific version.
sourcepub fn is_candidate(reader: impl Read + Seek) -> Result<bool>
pub fn is_candidate(reader: impl Read + Seek) -> Result<bool>
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.
sourcepub fn skip(reader: impl Read + Seek) -> Result<bool>
pub fn skip(reader: impl Read + Seek) -> Result<bool>
Detects the presence of an ID3v2 tag at the current position of the reader and skips it if is found. Returns true if a tag was found.
sourcepub fn remove_from_path(path: impl AsRef<Path>) -> Result<bool>
pub fn remove_from_path(path: impl AsRef<Path>) -> Result<bool>
Removes an ID3v2 tag from the file at the specified path.
Returns true if the file initially contained a tag.
sourcepub fn remove_from_file(file: &mut File) -> Result<bool>
pub fn remove_from_file(file: &mut File) -> Result<bool>
Removes an ID3v2 tag from the specified file.
Returns true if the file initially contained a tag.
sourcepub fn read_from(reader: impl Read) -> Result<Tag>
pub fn read_from(reader: impl Read) -> Result<Tag>
Attempts to read an ID3 tag from the reader.
sourcepub fn read_from_path(path: impl AsRef<Path>) -> Result<Tag>
pub fn read_from_path(path: impl AsRef<Path>) -> Result<Tag>
Attempts to read an ID3 tag from the file at the indicated path.
sourcepub fn read_from_aiff(reader: impl Read + Seek) -> Result<Tag>
pub fn read_from_aiff(reader: impl Read + Seek) -> Result<Tag>
Reads an AIFF stream and returns any present ID3 tag.
sourcepub fn read_from_aiff_path(path: impl AsRef<Path>) -> Result<Tag>
pub fn read_from_aiff_path(path: impl AsRef<Path>) -> Result<Tag>
Reads an AIFF file at the specified path and returns any present ID3 tag.
sourcepub fn read_from_aiff_file(file: &mut File) -> Result<Tag>
pub fn read_from_aiff_file(file: &mut File) -> Result<Tag>
Reads an AIFF file and returns any present ID3 tag.
sourcepub fn read_from_wav(reader: impl Read + Seek) -> Result<Tag>
pub fn read_from_wav(reader: impl Read + Seek) -> Result<Tag>
Reads an WAV stream and returns any present ID3 tag.
sourcepub fn read_from_wav_path(path: impl AsRef<Path>) -> Result<Tag>
pub fn read_from_wav_path(path: impl AsRef<Path>) -> Result<Tag>
Reads an WAV file at the specified path and returns any present ID3 tag.
sourcepub fn read_from_wav_file(file: &mut File) -> Result<Tag>
pub fn read_from_wav_file(file: &mut File) -> Result<Tag>
Reads an WAV file and returns any present ID3 tag.
sourcepub fn write_to(&self, writer: impl Write, version: Version) -> Result<()>
pub fn write_to(&self, writer: impl Write, version: Version) -> Result<()>
Attempts to write the ID3 tag to the writer using the specified version.
Note that the plain tag is written, regardless of the original contents. To safely encode a
tag to an MP3 file, use Tag::write_to_path
.
sourcepub fn write_to_path(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
pub fn write_to_path(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
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.
sourcepub fn write_to_aiff_path(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
pub fn write_to_aiff_path(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
Overwrite WAV file ID3 chunk in a file
sourcepub fn write_to_aiff_file(
&self,
file: &mut File,
version: Version
) -> Result<()>
pub fn write_to_aiff_file(
&self,
file: &mut File,
version: Version
) -> Result<()>
Overwrite AIFF file ID3 chunk in a file. The file must be opened read/write.
sourcepub fn write_to_wav_path(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
pub fn write_to_wav_path(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
Overwrite WAV file ID3 chunk
sourcepub fn write_to_wav_file(&self, file: &mut File, version: Version) -> Result<()>
pub fn write_to_wav_file(&self, file: &mut File, version: Version) -> Result<()>
Overwrite AIFF file ID3 chunk in a file. The file must be opened read/write.
sourcepub fn frames(&'a self) -> impl Iterator<Item = &'a Frame> + 'a
pub fn frames(&'a self) -> impl Iterator<Item = &'a Frame> + 'a
Returns an iterator over the all frames in the tag.
Example
use id3::{Content, Frame, Tag, TagLike};
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);
sourcepub fn extended_texts(&'a self) -> impl Iterator<Item = &'a ExtendedText> + 'a
pub fn extended_texts(&'a self) -> impl Iterator<Item = &'a ExtendedText> + 'a
Returns an iterator over the extended texts in the tag.
sourcepub fn extended_links(&'a self) -> impl Iterator<Item = &'a ExtendedLink> + 'a
pub fn extended_links(&'a self) -> impl Iterator<Item = &'a ExtendedLink> + 'a
Returns an iterator over the extended links in the tag.
sourcepub fn encapsulated_objects(
&'a self
) -> impl Iterator<Item = &'a EncapsulatedObject> + 'a
pub fn encapsulated_objects(
&'a self
) -> impl Iterator<Item = &'a EncapsulatedObject> + 'a
Returns an iterator over the General Encapsulated Object (GEOB) frames in the tag.
sourcepub fn comments(&'a self) -> impl Iterator<Item = &'a Comment> + 'a
pub fn comments(&'a self) -> impl Iterator<Item = &'a Comment> + 'a
Returns an iterator over the comments in the tag.
Example
use id3::{Frame, Tag, TagLike};
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);
sourcepub fn lyrics(&'a self) -> impl Iterator<Item = &'a Lyrics> + 'a
pub fn lyrics(&'a self) -> impl Iterator<Item = &'a Lyrics> + 'a
Returns an iterator over the lyrics frames in the tag.
sourcepub fn synchronised_lyrics(
&'a self
) -> impl Iterator<Item = &'a SynchronisedLyrics> + 'a
pub fn synchronised_lyrics(
&'a self
) -> impl Iterator<Item = &'a SynchronisedLyrics> + 'a
Returns an iterator over the synchronised lyrics frames in the tag.
sourcepub fn pictures(&'a self) -> impl Iterator<Item = &'a Picture> + 'a
pub fn pictures(&'a self) -> impl Iterator<Item = &'a Picture> + 'a
Returns an iterator over the pictures in the tag.
Example
use id3::{Frame, Tag, TagLike};
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);
sourcepub fn chapters(&self) -> impl Iterator<Item = &Chapter>
pub fn chapters(&self) -> impl Iterator<Item = &Chapter>
Returns an iterator over all chapters (CHAP) in the tag.
Example
use id3::{Tag, TagLike};
use id3::frame::{Chapter, Content, Frame};
let mut tag = Tag::new();
tag.add_frame(Chapter{
element_id: "01".to_string(),
start_time: 1000,
end_time: 2000,
start_offset: 0xff,
end_offset: 0xff,
frames: Vec::new(),
});
tag.add_frame(Chapter{
element_id: "02".to_string(),
start_time: 2000,
end_time: 3000,
start_offset: 0xff,
end_offset: 0xff,
frames: Vec::new(),
});
assert_eq!(2, tag.chapters().count());
Trait Implementations
sourceimpl Extend<Frame> for Tag
impl Extend<Frame> for Tag
sourcefn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<Frame> for Tag
impl FromIterator<Frame> for Tag
sourcefn from_iter<I: IntoIterator<Item = Frame>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Frame>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl TagLike for Tag
impl TagLike for Tag
sourcefn get(&self, id: impl AsRef<str>) -> Option<&Frame>
fn get(&self, id: impl AsRef<str>) -> Option<&Frame>
Returns a reference to the first frame with the specified identifier. Read more
sourcefn add_frame(&mut self, new_frame: impl Into<Frame>) -> Option<Frame>
fn add_frame(&mut self, new_frame: impl Into<Frame>) -> Option<Frame>
Adds the frame to the tag, replacing and returning any conflicting frame. Read more
sourcefn set_text(&mut self, id: impl AsRef<str>, text: impl Into<String>)
fn set_text(&mut self, id: impl AsRef<str>, text: impl Into<String>)
Adds a text frame. Read more
sourcefn set_text_values(
&mut self,
id: impl AsRef<str>,
texts: impl IntoIterator<Item = impl Into<String>>
)
fn set_text_values(
&mut self,
id: impl AsRef<str>,
texts: impl IntoIterator<Item = impl Into<String>>
)
Panics Read more
sourcefn remove(&mut self, id: impl AsRef<str>) -> Vec<Frame>
fn remove(&mut self, id: impl AsRef<str>) -> Vec<Frame>
Remove all frames with the specified identifier and return them. Read more
sourcefn year(&self) -> Option<i32>
fn year(&self) -> Option<i32>
Returns the year (TYER).
Returns None
if the year frame could not be found or if it could not be parsed. Read more
sourcefn remove_year(&mut self)
fn remove_year(&mut self)
Removes the year (TYER). Read more
sourcefn date_recorded(&self) -> Option<Timestamp>
fn date_recorded(&self) -> Option<Timestamp>
Return the content of the TRDC frame, if any Read more
sourcefn set_date_recorded(&mut self, timestamp: Timestamp)
fn set_date_recorded(&mut self, timestamp: Timestamp)
Sets the content of the TDRC frame Read more
sourcefn remove_date_recorded(&mut self)
fn remove_date_recorded(&mut self)
Remove the content of the TDRC frame Read more
sourcefn date_released(&self) -> Option<Timestamp>
fn date_released(&self) -> Option<Timestamp>
Return the content of the TDRL frame, if any Read more
sourcefn set_date_released(&mut self, timestamp: Timestamp)
fn set_date_released(&mut self, timestamp: Timestamp)
Sets the content of the TDRL frame Read more
sourcefn remove_date_released(&mut self)
fn remove_date_released(&mut self)
Remove the content of the TDRL frame Read more
sourcefn artists(&self) -> Option<Vec<&str>>
fn artists(&self) -> Option<Vec<&str>>
Returns the (potential) multiple artists (TPE1). Read more
sourcefn set_artist(&mut self, artist: impl Into<String>)
fn set_artist(&mut self, artist: impl Into<String>)
Sets the artist (TPE1). Read more
sourcefn remove_artist(&mut self)
fn remove_artist(&mut self)
Removes the artist (TPE1). Read more
sourcefn album_artist(&self) -> Option<&str>
fn album_artist(&self) -> Option<&str>
Sets the album artist (TPE2). Read more
sourcefn set_album_artist(&mut self, album_artist: impl Into<String>)
fn set_album_artist(&mut self, album_artist: impl Into<String>)
Sets the album artist (TPE2). Read more
sourcefn remove_album_artist(&mut self)
fn remove_album_artist(&mut self)
Removes the album artist (TPE2). Read more
sourcefn remove_album(&mut self)
fn remove_album(&mut self)
Removes the album (TALB). Read more
sourcefn remove_title(&mut self)
fn remove_title(&mut self)
Removes the title (TIT2). Read more
sourcefn set_duration(&mut self, duration: u32)
fn set_duration(&mut self, duration: u32)
Sets the duration (TLEN). Read more
sourcefn remove_duration(&mut self)
fn remove_duration(&mut self)
Removes the duration (TLEN). Read more
sourcefn genres(&self) -> Option<Vec<&str>>
fn genres(&self) -> Option<Vec<&str>>
Returns the (potential) multiple genres (TCON). Read more
sourcefn remove_genre(&mut self)
fn remove_genre(&mut self)
Removes the genre (TCON). Read more
sourcefn remove_disc(&mut self)
fn remove_disc(&mut self)
Removes the disc number (TPOS). Read more
sourcefn total_discs(&self) -> Option<u32>
fn total_discs(&self) -> Option<u32>
Returns the total number of discs (TPOS). Read more
sourcefn set_total_discs(&mut self, total_discs: u32)
fn set_total_discs(&mut self, total_discs: u32)
Sets the total number of discs (TPOS). Read more
sourcefn remove_total_discs(&mut self)
fn remove_total_discs(&mut self)
Removes the total number of discs (TPOS). Read more
sourcefn remove_track(&mut self)
fn remove_track(&mut self)
Removes the track number (TRCK). Read more
sourcefn total_tracks(&self) -> Option<u32>
fn total_tracks(&self) -> Option<u32>
Returns the total number of tracks (TRCK). Read more
sourcefn set_total_tracks(&mut self, total_tracks: u32)
fn set_total_tracks(&mut self, total_tracks: u32)
Sets the total number of tracks (TRCK). Read more
sourcefn remove_total_tracks(&mut self)
fn remove_total_tracks(&mut self)
Removes the total number of tracks (TCON). Read more
sourcefn add_extended_text(
&mut self,
description: impl Into<String>,
value: impl Into<String>
)
fn add_extended_text(
&mut self,
description: impl Into<String>,
value: impl Into<String>
)
Use add_frame(frame::ExtendedText{ .. })
Adds a user defined text frame (TXXX). Read more
sourcefn remove_extended_text(
&mut self,
description: Option<&str>,
value: Option<&str>
)
fn remove_extended_text(
&mut self,
description: Option<&str>,
value: Option<&str>
)
Removes the user defined text frame (TXXX) with the specified key and value. Read more
sourcefn add_picture(&mut self, picture: Picture)
fn add_picture(&mut self, picture: Picture)
Use add_frame(frame::Picture{ .. })
Adds a picture frame (APIC). Any other pictures with the same type will be removed from the tag. Read more
sourcefn remove_picture_by_type(&mut self, picture_type: PictureType)
fn remove_picture_by_type(&mut self, picture_type: PictureType)
Removes all pictures of the specified type. Read more
sourcefn remove_all_pictures(&mut self)
fn remove_all_pictures(&mut self)
Removes all pictures. Read more
sourcefn add_comment(&mut self, comment: Comment)
fn add_comment(&mut self, comment: Comment)
Use add_frame(frame::Comment{ .. })
Adds a comment (COMM). Read more
sourcefn remove_comment(&mut self, description: Option<&str>, text: Option<&str>)
fn remove_comment(&mut self, description: Option<&str>, text: Option<&str>)
Removes the comment (COMM) with the specified key and value. Read more
sourcefn add_encapsulated_object(
&mut self,
description: impl Into<String>,
mime_type: impl Into<String>,
filename: impl Into<String>,
data: impl Into<Vec<u8>>
)
fn add_encapsulated_object(
&mut self,
description: impl Into<String>,
mime_type: impl Into<String>,
filename: impl Into<String>,
data: impl Into<Vec<u8>>
)
Use add_frame(frame::EncapsulatedObject{ .. })
Adds an encapsulated object frame (GEOB). Read more
sourcefn remove_encapsulated_object(
&mut self,
description: Option<&str>,
mime_type: Option<&str>,
filename: Option<&str>,
data: Option<&[u8]>
)
fn remove_encapsulated_object(
&mut self,
description: Option<&str>,
mime_type: Option<&str>,
filename: Option<&str>,
data: Option<&[u8]>
)
Removes the encapsulated object frame (GEOB) with the specified key, MIME type, filename and data. Read more
sourcefn add_lyrics(&mut self, lyrics: Lyrics)
fn add_lyrics(&mut self, lyrics: Lyrics)
Use add_frame(frame::Lyrics{ .. })
Sets the lyrics (USLT). Read more
sourcefn remove_all_lyrics(&mut self)
fn remove_all_lyrics(&mut self)
Removes the lyrics text (USLT) from the tag. Read more
sourcefn add_synchronised_lyrics(&mut self, lyrics: SynchronisedLyrics)
fn add_synchronised_lyrics(&mut self, lyrics: SynchronisedLyrics)
Use add_frame(frame::SynchronisedLyrics{ .. })
Adds a synchronised lyrics frame (SYLT). Read more
sourcefn remove_all_synchronised_lyrics(&mut self)
fn remove_all_synchronised_lyrics(&mut self)
Removes all synchronised lyrics (SYLT) frames from the tag. Read more
sourcefn remove_all_chapters(&mut self)
fn remove_all_chapters(&mut self)
Adds a single chapter (CHAP) to the farme. Read more
impl Eq for Tag
impl StructuralEq for Tag
Auto Trait Implementations
impl RefUnwindSafe for Tag
impl Send for Tag
impl Sync for Tag
impl Unpin for Tag
impl UnwindSafe for Tag
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more