A library for reading and writing ID3 metadata.
```rust use id3::{Tag, TagLike};
fn main() -> Result<(), Box
// Get a bunch of frames...
if let Some(artist) = tag.artist() {
println!("artist: {}", artist);
}
if let Some(title) = tag.title() {
println!("title: {}", title);
}
if let Some(album) = tag.album() {
println!("album: {}", album);
}
// Get frames before getting their content for more complex tags.
if let Some(artist) = tag.get("TPE1").and_then(|frame| frame.content().text()) {
println!("artist: {}", artist);
}
Ok(())
} ```
```rust use id3::{Error, ErrorKind, Tag, TagLike, Version}; use std::fs::copy;
fn main() -> Result<(), Box
let mut tag = match Tag::read_from_path("/tmp/music.mp3") {
Ok(tag) => tag,
Err(Error{kind: ErrorKind::NoTag, ..}) => Tag::new(),
Err(err) => return Err(Box::new(err)),
};
tag.set_album("Fancy Album Title");
tag.write_to_path("/tmp/music.mp3", Version::Id3v24)?;
Ok(())
} ```
```rust use id3::{Tag, TagLike, Frame, Version}; use id3::frame::Content; use std::fs::copy;
fn main() -> Result<(), Box
let mut tag = Tag::new();
tag.set_album("Fancy Album Title");
// Set the album the hard way.
tag.add_frame(Frame::text("TALB", "album"));
tag.write_to_path("/tmp/music.mp3", Version::Id3v24)?;
Ok(())
} ```