Enum id3::frame::Content

source ·
#[non_exhaustive]
pub enum Content {
Show 15 variants Text(String), ExtendedText(ExtendedText), Link(String), ExtendedLink(ExtendedLink), Comment(Comment), Popularimeter(Popularimeter), Lyrics(Lyrics), SynchronisedLyrics(SynchronisedLyrics), Picture(Picture), EncapsulatedObject(EncapsulatedObject), Chapter(Chapter), MpegLocationLookupTable(MpegLocationLookupTable), Private(Private), TableOfContents(TableOfContents), Unknown(Unknown),
}
Expand description

The decoded contents of a Frame.

§Compatibility

It is important to note that the ID3 spec has a variety of extensions of which not all are implemented by this library. When a new frame content type is added, the signature of this enum changes. Hence, the non_exhaustive attribute is set.

However, when a new frame type variant is added, frames that would previously decode to Unknown are now decoded to their new variants. This would break user code, such as custom decoders, that was expecting Unknown.

In order to prevent breakage when this library adds a new frame type, users must use the Content::to_unknown method which will return an Unknown regardlesss of whether the frame content was successfully decoded.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Text(String)

A value containing the parsed contents of a text frame.

§

ExtendedText(ExtendedText)

A value containing the parsed contents of a user defined text frame (TXXX).

A value containing the parsed contents of a web link frame.

A value containing the parsed contents of a user defined web link frame (WXXX).

§

Comment(Comment)

A value containing the parsed contents of a comment frame (COMM).

§

Popularimeter(Popularimeter)

Popularimeter frame content (POPM).

§

Lyrics(Lyrics)

A value containing the parsed contents of a lyrics frame (USLT).

§

SynchronisedLyrics(SynchronisedLyrics)

A value containing the parsed contents of a synchronised lyrics frame (SYLT).

§

Picture(Picture)

A value containing the parsed contents of a picture frame (APIC).

§

EncapsulatedObject(EncapsulatedObject)

A value containing the parsed contents of a general encapsulated object frame (GEOB).

§

Chapter(Chapter)

A chapter object containing frames by itself (CHAP).

§

MpegLocationLookupTable(MpegLocationLookupTable)

MPEG location lookup table content (MLLT).

§

Private(Private)

A private frame (PRIV)

§

TableOfContents(TableOfContents)

A value containing the parsed contents of a table of contents frame (CTOC).

§

Unknown(Unknown)

A value containing the bytes of a currently unknown frame type.

Users that wish to write custom decoders must use Content::to_unknown instead of matching on this variant. See the compatibility note in the top level enum docs.

Implementations§

source§

impl Content

source

pub fn new_text_values( texts: impl IntoIterator<Item = impl Into<String>> ) -> Self

Constructs a new Text Content from the specified set of strings.

§Panics

If any of the strings contain a null byte.

§Example
use id3::frame::Content;

let c = Content::new_text_values(["foo", "bar", "baz"]);
assert_eq!(c, Content::Text("foo\u{0}bar\u{0}baz".to_string()))
source

pub fn text(&self) -> Option<&str>

Returns the Text or None if the value is not Text.

source

pub fn text_values(&self) -> Option<impl Iterator<Item = &str>>

Returns split values of the Text frame or None if the value is not Text. This is only useful for ID3v2.4 tags, which support text frames containing multiple values separated by null bytes. This method returns an iterator over the separated values.

source

pub fn extended_text(&self) -> Option<&ExtendedText>

Returns the ExtendedText or None if the value is not ExtendedText.

Returns the Link or None if the value is not Link.

Returns the ExtendedLink or None if the value is not ExtendedLink.

source

pub fn encapsulated_object(&self) -> Option<&EncapsulatedObject>

Returns the EncapsulatedObject or None if the value is not EncapsulatedObject.

source

pub fn comment(&self) -> Option<&Comment>

Returns the Comment or None if the value is not Comment.

source

pub fn lyrics(&self) -> Option<&Lyrics>

Returns the Lyrics or None if the value is not Lyrics.

source

pub fn synchronised_lyrics(&self) -> Option<&SynchronisedLyrics>

Returns the SynchronisedLyrics or None if the value is not SynchronisedLyrics.

source

pub fn picture(&self) -> Option<&Picture>

Returns the Picture or None if the value is not Picture.

source

pub fn chapter(&self) -> Option<&Chapter>

Returns the Chapter or None if the value is not Chapter.

source

pub fn mpeg_location_lookup_table(&self) -> Option<&MpegLocationLookupTable>

Returns the MpegLocationLookupTable or None if the value is not MpegLocationLookupTable.

source

pub fn popularimeter(&self) -> Option<&Popularimeter>

Returns the Popularimeter or None if the value is not Popularimeter

source

pub fn table_of_contents(&self) -> Option<&TableOfContents>

Returns the TableOfContents or None if the value is not TableOfContents.

source

pub fn unknown(&self) -> Option<&[u8]>

👎Deprecated: Use to_unknown

Returns the Unknown or None if the value is not Unknown.

source

pub fn to_unknown(&self) -> Result<Cow<'_, Unknown>>

Returns the Unknown variant or an ad-hoc encoding of any other variant.

See the compatibility note on the docs of Content for the reason of why this function exists.

Trait Implementations§

source§

impl Clone for Content

source§

fn clone(&self) -> Content

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 Content

source§

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

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

impl Display for Content

source§

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

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

impl Hash for Content

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Content

source§

fn cmp(&self, other: &Content) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Content

source§

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

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

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

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

impl PartialOrd for Content

source§

fn partial_cmp(&self, other: &Content) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for Content

source§

impl StructuralPartialEq for Content

Auto Trait Implementations§

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> 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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.