Struct lofty::ape::ApeTag

source ·
pub struct ApeTag {
    pub read_only: bool,
    /* private fields */
}
Expand description

An APE tag

Supported file types

Item storage

APE isn’t a very strict format. An ApeItem only restricted by its name, meaning it can use a normal ItemValue unlike other formats.

Pictures are stored as ItemValue::Binary, and can be converted with Picture::from_ape_bytes. For the appropriate item keys, see APE_PICTURE_TYPES.

Conversions

To Tag

Any ApeItem with an ItemKey mapping will have a 1:1 conversion to TagItem.

From Tag

When converting pictures, any of type PictureType::Undefined will be discarded. For items, see ApeItem::new.

Fields§

§read_only: bool

Whether or not to mark the tag as read only

Implementations§

source§

impl ApeTag

source

pub fn new() -> Self

Create a new empty ApeTag

Examples
use lofty::ape::ApeTag;
use lofty::TagExt;

let ape_tag = ApeTag::new();
assert!(ape_tag.is_empty());
source

pub fn get(&self, key: &str) -> Option<&ApeItem>

Get an ApeItem by key

NOTE: While APE items are supposed to be case-sensitive, this rule is rarely followed, so this will ignore case when searching.

Examples
use lofty::ape::ApeTag;
use lofty::Accessor;

let mut ape_tag = ApeTag::new();
ape_tag.set_title(String::from("Foo title"));

// Get the title by its key
let title = ape_tag.get("Title");
assert!(title.is_some());
source

pub fn insert(&mut self, value: ApeItem)

Insert an ApeItem

This will remove any item with the same key prior to insertion

source

pub fn remove(&mut self, key: &str)

Remove an ApeItem by key

NOTE: Like ApeTag::get, this is not case-sensitive

Examples
use lofty::ape::ApeTag;
use lofty::Accessor;

let mut ape_tag = ApeTag::new();
ape_tag.set_title(String::from("Foo title"));

// Get the title by its key
let title = ape_tag.get("Title");
assert!(title.is_some());

// Remove the title
ape_tag.remove("Title");

let title = ape_tag.get("Title");
assert!(title.is_none());

Trait Implementations§

source§

impl Accessor for ApeTag

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 ApeTag

source§

fn clone(&self) -> ApeTag

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 ApeTag

source§

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

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

impl Default for ApeTag

source§

fn default() -> ApeTag

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

impl From<ApeTag> for Tag

source§

fn from(input: ApeTag) -> Self

Converts to this type from the input type.
source§

impl From<Tag> for ApeTag

source§

fn from(input: Tag) -> Self

Converts to this type from the input type.
source§

impl<'a> IntoIterator for &'a ApeTag

§

type Item = &'a ApeItem

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, ApeItem>

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 ApeTag

§

type Item = ApeItem

The type of the elements being iterated over.
§

type IntoIter = IntoIter<<ApeTag 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 ApeTag

source§

fn eq(&self, other: &ApeTag) -> 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 SplitTag for ApeTag

§

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 ApeTag

source§

fn save_to(&self, file: &mut File) -> Result<(), Self::Err>

Write an APE tag to a file

Errors
  • Attempting to write the tag to a format that does not support it
  • An existing tag has an invalid size
source§

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

Dumps the tag to a writer

Errors
§

type Err = LoftyError

The associated error which can be returned from IO operations
§

type RefKey<'a> = &'a str

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 remove_from_path<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Err>

Remove a tag from a Path Read more
source§

fn remove_from(&self, file: &mut File) -> Result<(), Self::Err>

Remove a tag from a File 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) -> Result<(), Self::Err>

Save the tag to a path Read more
source§

impl Eq for ApeTag

source§

impl StructuralEq for ApeTag

source§

impl StructuralPartialEq for ApeTag

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