Struct lofty::mp4::Ilst

source ·
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

source

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());
source

pub fn get(&self, ident: &AtomIdent<'_>) -> Option<&Atom<'static>>

Get an item by its AtomIdent

§Examples
use lofty::mp4::{AtomIdent, Ilst};
use lofty::tag::Accessor;

let mut ilst = Ilst::new();
ilst.set_title(String::from("Foo title"));

// Get the title by its FOURCC identifier
let title = ilst.get(&AtomIdent::Fourcc(*b"\xa9nam"));
assert!(title.is_some());
source

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());
source

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"));
source

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());
source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&Atom<'_>) -> bool,

Retain atoms based on the predicate

See Vec::retain

source

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);
source

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);
source

pub fn remove_pictures(&mut self)

Removes all pictures

source

pub fn advisory_rating(&self) -> Option<AdvisoryRating>

Returns the parental advisory rating according to the rtng atom

source

pub fn set_advisory_rating(&mut self, advisory_rating: AdvisoryRating)

Sets the advisory rating

Trait Implementations§

source§

impl Accessor for Ilst

source§

fn artist(&self) -> Option<Cow<'_, str>>

Returns the artist Read more
source§

fn set_artist(&mut self, value: String)

Sets the artist Read more
source§

fn remove_artist(&mut self)

Removes the artist Read more
source§

fn title(&self) -> Option<Cow<'_, str>>

Returns the title Read more
source§

fn set_title(&mut self, value: String)

Sets the title Read more
source§

fn remove_title(&mut self)

Removes the title Read more
source§

fn album(&self) -> Option<Cow<'_, str>>

Returns the album Read more
source§

fn set_album(&mut self, value: String)

Sets the album Read more
source§

fn remove_album(&mut self)

Removes the album Read more
source§

fn genre(&self) -> Option<Cow<'_, str>>

Returns the genre Read more
source§

fn set_genre(&mut self, value: String)

Sets the genre Read more
source§

fn remove_genre(&mut self)

Removes the genre Read more
source§

fn comment(&self) -> Option<Cow<'_, str>>

Returns the comment Read more
source§

fn set_comment(&mut self, value: String)

Sets the comment Read more
source§

fn remove_comment(&mut self)

Removes the comment Read more
source§

fn track(&self) -> Option<u32>

Returns the track Read more
source§

fn set_track(&mut self, value: u32)

Sets the track Read more
source§

fn remove_track(&mut self)

Removes the track Read more
source§

fn track_total(&self) -> Option<u32>

Returns the track total Read more
source§

fn set_track_total(&mut self, value: u32)

Sets the track total Read more
source§

fn remove_track_total(&mut self)

Removes the track total Read more
source§

fn disk(&self) -> Option<u32>

Returns the disk Read more
source§

fn set_disk(&mut self, value: u32)

Sets the disk Read more
source§

fn remove_disk(&mut self)

Removes the disk Read more
source§

fn disk_total(&self) -> Option<u32>

Returns the disk total Read more
source§

fn set_disk_total(&mut self, value: u32)

Sets the disk total Read more
source§

fn remove_disk_total(&mut self)

Removes the disk total Read more
source§

fn year(&self) -> Option<u32>

Returns the year Read more
source§

fn set_year(&mut self, value: u32)

Sets the year Read more
source§

fn remove_year(&mut self)

Removes the year Read more
source§

impl Clone for Ilst

source§

fn clone(&self) -> Ilst

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Ilst

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Ilst

source§

fn default() -> Ilst

Returns the “default value” for a type. Read more
source§

impl From<Ilst> for Tag

source§

fn from(input: Ilst) -> Self

Converts to this type from the input type.
source§

impl From<Tag> for Ilst

source§

fn from(input: Tag) -> Self

Converts to this type from the input type.
source§

impl<'a> IntoIterator for &'a Ilst

source§

type Item = &'a Atom<'static>

The type of the elements being iterated over.
source§

type IntoIter = Iter<'a, Atom<'static>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for Ilst

source§

type Item = Atom<'static>

The type of the elements being iterated over.
source§

type IntoIter = IntoIter<<Ilst as IntoIterator>::Item>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for Ilst

source§

fn eq(&self, other: &Ilst) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SplitTag for Ilst

source§

type Remainder = SplitTagRemainder

The remainder of the split operation that is not represented in the resulting Tag.
source§

fn split_tag(self) -> (Self::Remainder, Tag)

Extract and split generic contents into a Tag. Read more
source§

impl TagExt for Ilst

source§

type Err = LoftyError

The associated error which can be returned from IO operations
source§

type RefKey<'a> = &'a AtomIdent<'a>

The type of key used in the tag for non-mutating functions
source§

fn len(&self) -> usize

Returns the number of items in the tag Read more
source§

fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool

Whether the tag contains an item with the key Read more
source§

fn is_empty(&self) -> bool

Whether the tag has any items Read more
source§

fn save_to<F>( &self, file: &mut F, write_options: WriteOptions, ) -> Result<(), Self::Err>
where F: FileLike, LoftyError: From<<F as Truncate>::Error> + From<<F as Length>::Error>,

Save the tag to a FileLike Read more
source§

fn dump_to<W: Write>( &self, writer: &mut W, write_options: WriteOptions, ) -> Result<(), Self::Err>

Dump the tag to a writer Read more
source§

fn clear(&mut self)

Clear the tag, removing all items Read more
source§

fn save_to_path<P: AsRef<Path>>( &self, path: P, write_options: WriteOptions, ) -> Result<(), Self::Err>

Save the tag to a path Read more
source§

fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Err>

Remove a tag from a Path Read more
source§

fn remove_from<F>(&self, file: &mut F) -> Result<(), Self::Err>
where F: FileLike, LoftyError: From<<F as Truncate>::Error> + From<<F as Length>::Error>,

Remove a tag from a FileLike Read more
source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.