Struct id3::frame::Frame

source ·
pub struct Frame { /* private fields */ }
Expand description

A structure representing an ID3 frame.

The Content must be accompanied by a matching ID. Although this struct allows for invalid combinations to exist, attempting to encode them will yield an error.

Implementations§

source§

impl Frame

source

pub fn with_content(id: impl AsRef<str>, content: Content) -> Self

Creates a frame with the specified ID and content.

Both ID3v2.2 and >ID3v2.3 IDs are accepted, although they will be converted to ID3v2.3 format. If an ID3v2.2 ID is supplied but could not be remapped, it is stored as-is.

§Panics

If the id’s length is not 3 or 4 bytes long.

source

pub fn set_encoding(self, encoding: Option<Encoding>) -> Self

Sets the encoding for this frame.

The encoding is actually a property of individual content and its serialization format. Public interfaces of ID3 typically follow Rust conventions such as UTF-8.

§Caveat

According to the standard, distinct encodings do not count towards uniqueness. However, some applications such as Serato do write multiple frames that should not co-exist in a single tag and uses the encoding to distinguish between such frames.

When set using this function, the encoding influences the way uniqueness is determined and using other interfaces to alter the tag this frame belongs to has the potential to remove this or other tags.

After decoding a tag, the initial encoding is only set for TXXX and GEOB frames.

source

pub fn text(id: impl AsRef<str>, content: impl Into<String>) -> Self

Creates a new text frame with the specified ID and text content.

This function does not verify whether the ID is valid for text frames.

§Example
use id3::Frame;

let frame = Frame::text("TPE1", "Armin van Buuren");
assert_eq!(frame.content().text(), Some("Armin van Buuren"));

Creates a new link frame with the specified ID and link content.

This function does not verify whether the ID is valid for link frames.

§Example
use id3::Frame;

let frame = Frame::link("WCOM", "https://wwww.arminvanbuuren.com");
assert_eq!(frame.content().link(), Some("https://wwww.arminvanbuuren.com"));
source

pub fn id(&self) -> &str

Returns the ID of this frame.

The string returned us usually 4 bytes long except when the frame was read from an ID3v2.2 tag and the ID could not be mapped to an ID3v2.3 ID.

source

pub fn id_for_version(&self, version: Version) -> Option<&str>

Returns the ID that is compatible with specified version or None if no ID is available in that version.

source

pub fn content(&self) -> &Content

Returns the content of the frame.

source

pub fn tag_alter_preservation(&self) -> bool

Returns whether the tag_alter_preservation flag is set.

source

pub fn set_tag_alter_preservation(&mut self, tag_alter_preservation: bool)

Sets the tag_alter_preservation flag.

source

pub fn file_alter_preservation(&self) -> bool

Returns whether the file_alter_preservation flag is set.

source

pub fn set_file_alter_preservation(&mut self, file_alter_preservation: bool)

Sets the file_alter_preservation flag.

source

pub fn encoding(&self) -> Option<Encoding>

Returns the encoding of this frame

§Caveat

See Frame::set_encoding.

source

pub fn name(&self) -> &str

Returns the name of the frame.

The name is the human-readable representation of a frame id. For example, the id "TCOM" corresponds to the name "Composer". The names are taken from the ID3v2.4, ID3v2.3 and ID3v2.2 standards.

Trait Implementations§

source§

impl Clone for Frame

source§

fn clone(&self) -> Frame

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 Frame

source§

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

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

impl Display for Frame

source§

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

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

impl Extend<Frame> for Chapter

source§

fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Frame> for TableOfContents

source§

fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Frame> for Tag

source§

fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl From<Chapter> for Frame

source§

fn from(c: Chapter) -> Self

Converts to this type from the input type.
source§

impl From<Comment> for Frame

source§

fn from(c: Comment) -> Self

Converts to this type from the input type.
source§

impl From<EncapsulatedObject> for Frame

source§

fn from(c: EncapsulatedObject) -> Self

Converts to this type from the input type.
source§

impl From<ExtendedLink> for Frame

source§

fn from(c: ExtendedLink) -> Self

Converts to this type from the input type.
source§

impl From<ExtendedText> for Frame

source§

fn from(c: ExtendedText) -> Self

Converts to this type from the input type.
source§

impl From<Lyrics> for Frame

source§

fn from(c: Lyrics) -> Self

Converts to this type from the input type.
source§

impl From<MpegLocationLookupTable> for Frame

source§

fn from(c: MpegLocationLookupTable) -> Self

Converts to this type from the input type.
source§

impl From<Picture> for Frame

source§

fn from(c: Picture) -> Self

Converts to this type from the input type.
source§

impl From<Popularimeter> for Frame

source§

fn from(c: Popularimeter) -> Self

Converts to this type from the input type.
source§

impl From<Private> for Frame

source§

fn from(c: Private) -> Self

Converts to this type from the input type.
source§

impl From<SynchronisedLyrics> for Frame

source§

fn from(c: SynchronisedLyrics) -> Self

Converts to this type from the input type.
source§

impl From<TableOfContents> for Frame

source§

fn from(c: TableOfContents) -> Self

Converts to this type from the input type.
source§

impl FromIterator<Frame> for Tag

source§

fn from_iter<I: IntoIterator<Item = Frame>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl Hash for Frame

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 Frame

source§

fn cmp(&self, other: &Frame) -> 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 Frame

source§

fn eq(&self, other: &Self) -> 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 Frame

source§

fn partial_cmp(&self, other: &Frame) -> 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 Frame

Auto Trait Implementations§

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnwindSafe for Frame

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.