Struct id3::Tag [−][src]
pub struct Tag { /* fields omitted */ }
An ID3 tag containing metadata frames.
Implementations
impl<'a> Tag
[src]
pub fn new() -> Tag
[src]
Creates a new ID3v2.4 tag with no frames.
pub fn frames(&'a self) -> impl Iterator<Item = &'a Frame> + 'a
[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);
pub fn extended_texts(&'a self) -> impl Iterator<Item = &'a ExtendedText> + 'a
[src]
Returns an iterator over the extended texts in the tag.
pub fn extended_links(&'a self) -> impl Iterator<Item = &'a ExtendedLink> + 'a
[src]
Returns an iterator over the extended links in the tag.
pub fn encapsulated_objects(
&'a self
) -> impl Iterator<Item = &'a EncapsulatedObject> + 'a
[src]
&'a self
) -> impl Iterator<Item = &'a EncapsulatedObject> + 'a
Returns an iterator over the General Encapsulated Object (GEOB) frames in the tag.
pub fn comments(&'a self) -> impl Iterator<Item = &'a Comment> + 'a
[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);
pub fn lyrics(&'a self) -> impl Iterator<Item = &'a Lyrics> + 'a
[src]
Returns an iterator over the lyrics frames in the tag.
pub fn synchronised_lyrics(
&'a self
) -> impl Iterator<Item = &'a SynchronisedLyrics> + 'a
[src]
&'a self
) -> impl Iterator<Item = &'a SynchronisedLyrics> + 'a
Returns an iterator over the synchronised lyrics frames in the tag.
pub fn pictures(&'a self) -> impl Iterator<Item = &'a Picture> + 'a
[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);
pub fn get(&self, id: impl AsRef<str>) -> Option<&Frame>
[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());
pub fn add_frame(&mut self, new_frame: Frame) -> Option<Frame>
[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");
pub fn set_text(&mut self, id: impl AsRef<str>, text: impl Into<String>)
[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");
pub fn remove(&mut self, id: impl AsRef<str>)
[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);
pub fn add_encapsulated_object(
&mut self,
description: impl Into<String>,
mime_type: impl Into<String>,
filename: impl Into<String>,
data: impl Into<Vec<u8>>
)
[src]
&mut self,
description: impl Into<String>,
mime_type: impl Into<String>,
filename: impl Into<String>,
data: impl Into<Vec<u8>>
)
Adds an encapsulated object frame (GEOB).
Example
use id3::Tag; let mut tag = Tag::new(); tag.add_encapsulated_object("key1", "application/octet-stream", "", &b"\x00\x01\xAB"[..]); tag.add_encapsulated_object("key2", "application/json", "foo.json", &b"{ \"value\" }"[..]); assert_eq!(tag.encapsulated_objects().count(), 2); assert!(tag.encapsulated_objects().any(|t| t.description == "key1" && t.mime_type == "application/octet-stream" && t.filename == "" && t.data == b"\x00\x01\xAB")); assert!(tag.encapsulated_objects().any(|t| t.description == "key2" && t.mime_type == "application/json" && t.filename == "foo.json" && t.data == b"{ \"value\" }"));
pub fn remove_encapsulated_object(
&mut self,
description: Option<&str>,
mime_type: Option<&str>,
filename: Option<&str>,
data: Option<&[u8]>
)
[src]
&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.
A key or value may be None
to specify a wildcard value.
Example
use id3::Tag; let mut tag = Tag::new(); tag.add_encapsulated_object("key1", "application/octet-stream", "filename1", &b"value1"[..]); tag.add_encapsulated_object("key2", "text/plain", "filename2", &b"value2"[..]); tag.add_encapsulated_object("key3", "text/plain", "filename3", &b"value2"[..]); tag.add_encapsulated_object("key4", "application/octet-stream", "filename4", &b"value3"[..]); tag.add_encapsulated_object("key5", "application/octet-stream", "filename4", &b"value4"[..]); tag.add_encapsulated_object("key6", "application/octet-stream", "filename5", &b"value5"[..]); tag.add_encapsulated_object("key7", "application/octet-stream", "filename6", &b"value6"[..]); tag.add_encapsulated_object("key8", "application/octet-stream", "filename7", &b"value7"[..]); assert_eq!(tag.encapsulated_objects().count(), 8); tag.remove_encapsulated_object(Some("key1"), None, None, None); assert_eq!(tag.encapsulated_objects().count(), 7); tag.remove_encapsulated_object(None, Some("text/plain"), None, None); assert_eq!(tag.encapsulated_objects().count(), 5); tag.remove_encapsulated_object(None, None, Some("filename4"), None); assert_eq!(tag.encapsulated_objects().count(), 3); tag.remove_encapsulated_object(None, None, None, Some(&b"value5"[..])); assert_eq!(tag.encapsulated_objects().count(), 2); tag.remove_encapsulated_object(Some("key7"), None, Some("filename6"), None); assert_eq!(tag.encapsulated_objects().count(), 1); tag.remove_encapsulated_object(None, None, None, None); assert_eq!(tag.encapsulated_objects().count(), 0);
pub fn add_extended_text(
&mut self,
description: impl Into<String>,
value: impl Into<String>
)
[src]
&mut self,
description: impl Into<String>,
value: impl Into<String>
)
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"));
pub fn remove_extended_text(
&mut self,
description: Option<&str>,
value: Option<&str>
)
[src]
&mut self,
description: Option<&str>,
value: Option<&str>
)
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);
pub fn add_picture(&mut self, picture: Picture)
[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");
pub fn remove_picture_by_type(&mut self, picture_type: PictureType)
[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);
pub fn remove_all_pictures(&mut self)
[src]
Removes all pictures.
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_all_pictures(); assert_eq!(tag.pictures().count(), 0);
pub fn add_comment(&mut self, comment: Comment)
[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));
pub fn remove_comment(&mut self, description: Option<&str>, text: Option<&str>)
[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);
pub fn year(&self) -> Option<i32>
[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());
pub fn set_year(&mut self, year: i32)
[src]
Sets the year (TYER).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_year(2014); assert_eq!(tag.year().unwrap(), 2014);
pub fn remove_year(&mut self)
[src]
Removes the year (TYER).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_year(2014); assert!(tag.year().is_some()); tag.remove_year(); assert!(tag.year().is_none());
pub fn date_recorded(&self) -> Option<Timestamp>
[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);
pub fn set_date_recorded(&mut self, timestamp: Timestamp)
[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);
pub fn remove_date_recorded(&mut self)
[src]
Remove 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!(tag.date_recorded().is_some()); tag.remove_date_recorded(); assert!(tag.date_recorded().is_none());
pub fn date_released(&self) -> Option<Timestamp>
[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);
pub fn set_date_released(&mut self, timestamp: Timestamp)
[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);
pub fn remove_date_released(&mut self)
[src]
Remove 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!(tag.date_released().is_some()); tag.remove_date_released(); assert!(tag.date_released().is_none());
pub fn artist(&self) -> Option<&str>
[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");
pub fn set_artist(&mut self, artist: impl Into<String>)
[src]
Sets the artist (TPE1).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_artist("artist"); assert_eq!(tag.artist().unwrap(), "artist");
pub fn remove_artist(&mut self)
[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());
pub fn album_artist(&self) -> Option<&str>
[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");
pub fn set_album_artist(&mut self, album_artist: impl Into<String>)
[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");
pub fn remove_album_artist(&mut self)
[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());
pub fn album(&self) -> Option<&str>
[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");
pub fn set_album(&mut self, album: impl Into<String>)
[src]
Sets the album (TALB).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_album("album"); assert_eq!(tag.album().unwrap(), "album");
pub fn remove_album(&mut self)
[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());
pub fn title(&self) -> Option<&str>
[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");
pub fn set_title(&mut self, title: impl Into<String>)
[src]
Sets the title (TIT2).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_title("title"); assert_eq!(tag.title().unwrap(), "title");
pub fn remove_title(&mut self)
[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());
pub fn duration(&self) -> Option<u32>
[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);
pub fn set_duration(&mut self, duration: u32)
[src]
Sets the duration (TLEN).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_duration(350); assert_eq!(tag.duration().unwrap(), 350);
pub fn remove_duration(&mut self)
[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());
pub fn genre(&self) -> Option<&str>
[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");
pub fn set_genre(&mut self, genre: impl Into<String>)
[src]
Sets the genre (TCON).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_genre("genre"); assert_eq!(tag.genre().unwrap(), "genre");
pub fn remove_genre(&mut self)
[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());
pub fn disc(&self) -> Option<u32>
[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());
pub fn set_disc(&mut self, disc: u32)
[src]
Sets the disc (TPOS).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_disc(2); assert_eq!(tag.disc().unwrap(), 2);
pub fn remove_disc(&mut self)
[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());
pub fn total_discs(&self) -> Option<u32>
[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());
pub fn set_total_discs(&mut self, total_discs: u32)
[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);
pub fn remove_total_discs(&mut self)
[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());
pub fn track(&self) -> Option<u32>
[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());
pub fn set_track(&mut self, track: u32)
[src]
Sets the track (TRCK).
Example
use id3::Tag; let mut tag = Tag::new(); tag.set_track(10); assert_eq!(tag.track().unwrap(), 10);
pub fn remove_track(&mut self)
[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());
pub fn total_tracks(&self) -> Option<u32>
[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());
pub fn set_total_tracks(&mut self, total_tracks: u32)
[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);
pub fn remove_total_tracks(&mut self)
[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());
pub fn add_lyrics(&mut self, lyrics: Lyrics)
[src]
Sets the lyrics (USLT).
Example
use id3::Tag; use id3::frame::Lyrics; let mut tag = Tag::new(); tag.add_lyrics(Lyrics { lang: "eng".to_string(), description: "".to_string(), text: "The lyrics".to_string(), }); assert_eq!(tag.lyrics().nth(0).unwrap().text, "The lyrics");
pub fn remove_all_lyrics(&mut self)
[src]
Removes the lyrics text (USLT) from the tag.
Example
use id3::Tag; use id3::frame::Lyrics; let mut tag = Tag::new(); tag.add_lyrics(Lyrics { lang: "eng".to_string(), description: "".to_string(), text: "The lyrics".to_string(), }); assert_eq!(1, tag.lyrics().count()); tag.remove_all_lyrics(); assert_eq!(0, tag.lyrics().count());
pub fn add_synchronised_lyrics(&mut self, lyrics: SynchronisedLyrics)
[src]
Adds a synchronised lyrics frame (SYLT).
Example
use id3::Tag; use id3::frame::{SynchronisedLyrics, SynchronisedLyricsType, TimestampFormat}; let mut tag = Tag::new(); tag.add_synchronised_lyrics(SynchronisedLyrics { lang: "eng".to_string(), timestamp_format: TimestampFormat::MS, content_type: SynchronisedLyricsType::Lyrics, content: vec![ (1000, "he".to_string()), (1100, "llo".to_string()), (1200, "world".to_string()), ], }); assert_eq!(1, tag.synchronised_lyrics().count());
pub fn remove_all_synchronised_lyrics(&mut self)
[src]
Removes all synchronised lyrics (SYLT) frames from the tag.
Example
use id3::Tag; use id3::frame::{SynchronisedLyrics, SynchronisedLyricsType, TimestampFormat}; let mut tag = Tag::new(); tag.add_synchronised_lyrics(SynchronisedLyrics { lang: "eng".to_string(), timestamp_format: TimestampFormat::MS, content_type: SynchronisedLyricsType::Lyrics, content: vec![ (1000, "he".to_string()), (1100, "llo".to_string()), (1200, "world".to_string()), ], }); assert_eq!(1, tag.synchronised_lyrics().count()); tag.remove_all_synchronised_lyrics(); assert_eq!(0, tag.synchronised_lyrics().count());
pub fn is_candidate(reader: impl Read + Seek) -> Result<bool>
[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.
pub fn skip(reader: impl Read + Seek) -> Result<bool>
[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.
pub fn read_from(reader: impl Read) -> Result<Tag>
[src]
Attempts to read an ID3 tag from the reader.
pub fn read_from_path(path: impl AsRef<Path>) -> Result<Tag>
[src]
Attempts to read an ID3 tag from the file at the indicated path.
pub fn write_to(&self, writer: impl Write, version: Version) -> Result<()>
[src]
Attempts to write the ID3 tag to the writer using the specified version.
pub fn write_to_path(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
[src]
&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.
pub fn remove_from(file: &mut File) -> Result<bool>
[src]
Removes an ID3v2 tag from the specified file.
Returns true if the file initially contained a tag.
pub fn read_from_aiff(path: impl AsRef<Path>) -> Result<Tag>
[src]
Reads AIFF file and returns ID3 Tag from it
pub fn read_from_aiff_reader(reader: impl Read + Seek) -> Result<Tag>
[src]
Read ID3 tag from AIFF data in reader
pub fn write_to_aiff(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
[src]
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
Overwrite AIFF file ID3 chunk
pub fn read_from_wav(path: impl AsRef<Path>) -> Result<Tag>
[src]
Reads WAV file and returns ID3 Tag from the ID3 chunk, if present.
pub fn read_from_wav_reader(reader: impl Read + Seek) -> Result<Tag>
[src]
Read ID3 tag from WAV data in reader
pub fn write_to_wav(
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
[src]
&self,
path: impl AsRef<Path>,
version: Version
) -> Result<()>
Overwrite WAV file ID3 chunk
Trait Implementations
impl Clone for Tag
[src]
impl Debug for Tag
[src]
impl Default for Tag
[src]
impl Eq for Tag
[src]
impl From<Tag> for Tag
[src]
impl PartialEq<Tag> for Tag
[src]
impl StructuralEq for Tag
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,