pub struct Ilst { /* private fields */ }Expand description
An MP4 ilst atom
§Supported file types
§Pictures
Unlike other formats, ilst does not store a PictureType. All pictures will have
PictureType::Other.
§Conversions
§To Tag
When converting to Tag, only atoms with a value of AtomData::UTF8 and AtomData::UTF16,
with the exception of the trkn and disk atoms, as well as pictures, will be preserved.
Do note, all pictures will be PictureType::Other
§From Tag
When converting from Tag, only items with a value of ItemValue::Text, as
well as pictures, will be preserved.
An attempt will be made to create the TrackNumber/TrackTotal (trkn) and DiscNumber/DiscTotal (disk) pairs.
Implementations§
source§impl Ilst
impl Ilst
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty Ilst
§Examples
use lofty::mp4::Ilst;
use lofty::tag::TagExt;
let ilst_tag = Ilst::new();
assert!(ilst_tag.is_empty());sourcepub fn insert(&mut self, atom: Atom<'static>)
pub fn insert(&mut self, atom: Atom<'static>)
Inserts an Atom
NOTE: Do not use this to replace atoms. This will take the value from the provided atom and
merge it into an atom of the same type, keeping any existing value(s). To ensure an atom
is replaced, use Ilst::replace_atom.
§Examples
use lofty::mp4::{Atom, AtomData, AtomIdent, Ilst};
const TITLE_IDENTIFIER: AtomIdent = AtomIdent::Fourcc(*b"\xa9nam");
let mut ilst = Ilst::new();
// Set the title by manually constructing an `Atom`
let title_atom = Atom::new(TITLE_IDENTIFIER, AtomData::UTF8(String::from("Foo title")));
ilst.insert(title_atom);
// Get the title by its FOURCC identifier
let title = ilst.get(&TITLE_IDENTIFIER);
assert!(title.is_some());sourcepub fn replace_atom(&mut self, atom: Atom<'_>)
pub fn replace_atom(&mut self, atom: Atom<'_>)
Inserts an Atom, replacing any atom with the same AtomIdent
§Examples
use lofty::mp4::{Atom, AtomData, AtomIdent, Ilst};
use lofty::tag::Accessor;
const TITLE_IDENTIFIER: AtomIdent = AtomIdent::Fourcc(*b"\xa9nam");
let mut ilst = Ilst::new();
ilst.set_title(String::from("FooBar"));
assert_eq!(ilst.title().as_deref(), Some("FooBar"));
// Replace our old title
ilst.replace_atom(Atom::new(
TITLE_IDENTIFIER,
AtomData::UTF8(String::from("BarFoo")),
));
assert_eq!(ilst.title().as_deref(), Some("BarFoo"));sourcepub fn remove(
&mut self,
ident: &AtomIdent<'_>,
) -> impl Iterator<Item = Atom<'static>> + '_
pub fn remove( &mut self, ident: &AtomIdent<'_>, ) -> impl Iterator<Item = Atom<'static>> + '_
Remove an atom by its AtomIdent
§Examples
use lofty::mp4::{Atom, AtomData, AtomIdent, Ilst};
use lofty::tag::Accessor;
const TITLE_IDENTIFIER: AtomIdent = AtomIdent::Fourcc(*b"\xa9nam");
let mut ilst = Ilst::new();
ilst.set_title(String::from("Foo title"));
// Get the title by its FOURCC identifier
let title = ilst.get(&TITLE_IDENTIFIER);
assert!(title.is_some());
// Remove the title
let returned = ilst.remove(&TITLE_IDENTIFIER);
assert_eq!(returned.count(), 1);
let title = ilst.get(&TITLE_IDENTIFIER);
assert!(title.is_none());sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retain atoms based on the predicate
See Vec::retain
sourcepub fn pictures(&self) -> Option<impl Iterator<Item = &Picture>>
pub fn pictures(&self) -> Option<impl Iterator<Item = &Picture>>
Returns all pictures, if there are any
§Examples
use lofty::mp4::Ilst;
use lofty::picture::{MimeType, Picture, PictureType};
use lofty::tag::TagExt;
let mut ilst = Ilst::new();
// Insert pictures
ilst.insert_picture(Picture::new_unchecked(
PictureType::Other,
Some(MimeType::Png),
None,
png_data,
));
ilst.insert_picture(Picture::new_unchecked(
PictureType::Other,
Some(MimeType::Jpeg),
None,
jpeg_data,
));
assert_eq!(ilst.pictures().unwrap().count(), 2);sourcepub fn insert_picture(&mut self, picture: Picture)
pub fn insert_picture(&mut self, picture: Picture)
Inserts a picture
NOTE: If a covr atom exists in the tag, the picture will be appended to it.
§Examples
use lofty::mp4::Ilst;
use lofty::picture::{MimeType, Picture, PictureType};
use lofty::tag::TagExt;
let mut ilst = Ilst::new();
// Insert a single picture
ilst.insert_picture(Picture::new_unchecked(
PictureType::Other,
Some(MimeType::Png),
None,
png_data,
));
assert_eq!(ilst.len(), 1);
// Insert another picture
ilst.insert_picture(Picture::new_unchecked(
PictureType::Other,
Some(MimeType::Jpeg),
None,
jpeg_data,
));
// The existing `covr` atom is reused
assert_eq!(ilst.len(), 1);
assert_eq!(ilst.pictures().unwrap().count(), 2);sourcepub fn remove_pictures(&mut self)
pub fn remove_pictures(&mut self)
Removes all pictures
sourcepub fn advisory_rating(&self) -> Option<AdvisoryRating>
pub fn advisory_rating(&self) -> Option<AdvisoryRating>
Returns the parental advisory rating according to the rtng atom
sourcepub fn set_advisory_rating(&mut self, advisory_rating: AdvisoryRating)
pub fn set_advisory_rating(&mut self, advisory_rating: AdvisoryRating)
Sets the advisory rating
Trait Implementations§
source§impl Accessor for Ilst
impl Accessor for Ilst
source§fn set_artist(&mut self, value: String)
fn set_artist(&mut self, value: String)
source§fn remove_artist(&mut self)
fn remove_artist(&mut self)
source§fn remove_title(&mut self)
fn remove_title(&mut self)
source§fn remove_album(&mut self)
fn remove_album(&mut self)
source§fn remove_genre(&mut self)
fn remove_genre(&mut self)
source§fn set_comment(&mut self, value: String)
fn set_comment(&mut self, value: String)
source§fn remove_comment(&mut self)
fn remove_comment(&mut self)
source§fn remove_track(&mut self)
fn remove_track(&mut self)
source§fn set_track_total(&mut self, value: u32)
fn set_track_total(&mut self, value: u32)
source§fn remove_track_total(&mut self)
fn remove_track_total(&mut self)
source§fn remove_disk(&mut self)
fn remove_disk(&mut self)
source§fn set_disk_total(&mut self, value: u32)
fn set_disk_total(&mut self, value: u32)
source§fn remove_disk_total(&mut self)
fn remove_disk_total(&mut self)
source§fn remove_year(&mut self)
fn remove_year(&mut self)
source§impl<'a> IntoIterator for &'a Ilst
impl<'a> IntoIterator for &'a Ilst
source§impl IntoIterator for Ilst
impl IntoIterator for Ilst
source§impl TagExt for Ilst
impl TagExt for Ilst
source§type Err = LoftyError
type Err = LoftyError
source§type RefKey<'a> = &'a AtomIdent<'a>
type RefKey<'a> = &'a AtomIdent<'a>
source§fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool
fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool
source§fn dump_to<W: Write>(
&self,
writer: &mut W,
write_options: WriteOptions,
) -> Result<(), Self::Err>
fn dump_to<W: Write>( &self, writer: &mut W, write_options: WriteOptions, ) -> Result<(), Self::Err>
source§fn save_to_path<P: AsRef<Path>>(
&self,
path: P,
write_options: WriteOptions,
) -> Result<(), Self::Err>
fn save_to_path<P: AsRef<Path>>( &self, path: P, write_options: WriteOptions, ) -> Result<(), Self::Err>
impl StructuralPartialEq for Ilst
Auto Trait Implementations§
impl Freeze for Ilst
impl RefUnwindSafe for Ilst
impl Send for Ilst
impl Sync for Ilst
impl Unpin for Ilst
impl UnwindSafe for Ilst
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)