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
impl Frame
sourcepub fn with_content(id: impl AsRef<str>, content: Content) -> Self
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.
sourcepub fn set_encoding(self, encoding: Option<Encoding>) -> Self
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.
sourcepub fn text(id: impl AsRef<str>, content: impl Into<String>) -> Self
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"));
sourcepub fn link(id: impl AsRef<str>, content: impl Into<String>) -> Self
pub fn link(id: impl AsRef<str>, content: impl Into<String>) -> Self
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"));
sourcepub fn id(&self) -> &str
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.
sourcepub fn id_for_version(&self, version: Version) -> Option<&str>
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.
sourcepub fn tag_alter_preservation(&self) -> bool
pub fn tag_alter_preservation(&self) -> bool
Returns whether the tag_alter_preservation flag is set.
sourcepub fn set_tag_alter_preservation(&mut self, tag_alter_preservation: bool)
pub fn set_tag_alter_preservation(&mut self, tag_alter_preservation: bool)
Sets the tag_alter_preservation flag.
sourcepub fn file_alter_preservation(&self) -> bool
pub fn file_alter_preservation(&self) -> bool
Returns whether the file_alter_preservation flag is set.
sourcepub fn set_file_alter_preservation(&mut self, file_alter_preservation: bool)
pub fn set_file_alter_preservation(&mut self, file_alter_preservation: bool)
Sets the file_alter_preservation flag.
Trait Implementations§
source§impl Extend<Frame> for Chapter
impl Extend<Frame> for Chapter
source§fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Extend<Frame> for TableOfContents
impl Extend<Frame> for TableOfContents
source§fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Extend<Frame> for Tag
impl Extend<Frame> for Tag
source§fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Frame>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl From<EncapsulatedObject> for Frame
impl From<EncapsulatedObject> for Frame
source§fn from(c: EncapsulatedObject) -> Self
fn from(c: EncapsulatedObject) -> Self
source§impl From<ExtendedLink> for Frame
impl From<ExtendedLink> for Frame
source§fn from(c: ExtendedLink) -> Self
fn from(c: ExtendedLink) -> Self
source§impl From<ExtendedText> for Frame
impl From<ExtendedText> for Frame
source§fn from(c: ExtendedText) -> Self
fn from(c: ExtendedText) -> Self
source§impl From<MpegLocationLookupTable> for Frame
impl From<MpegLocationLookupTable> for Frame
source§fn from(c: MpegLocationLookupTable) -> Self
fn from(c: MpegLocationLookupTable) -> Self
source§impl From<Popularimeter> for Frame
impl From<Popularimeter> for Frame
source§fn from(c: Popularimeter) -> Self
fn from(c: Popularimeter) -> Self
source§impl From<SynchronisedLyrics> for Frame
impl From<SynchronisedLyrics> for Frame
source§fn from(c: SynchronisedLyrics) -> Self
fn from(c: SynchronisedLyrics) -> Self
source§impl From<TableOfContents> for Frame
impl From<TableOfContents> for Frame
source§fn from(c: TableOfContents) -> Self
fn from(c: TableOfContents) -> Self
source§impl FromIterator<Frame> for Tag
impl FromIterator<Frame> for Tag
source§impl Ord for Frame
impl Ord for Frame
source§impl PartialEq for Frame
impl PartialEq for Frame
source§impl PartialOrd for Frame
impl PartialOrd for Frame
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more