Struct lofty::id3::v1::Id3v1Tag

source ·
pub struct Id3v1Tag {
    pub title: Option<String>,
    pub artist: Option<String>,
    pub album: Option<String>,
    pub year: Option<String>,
    pub comment: Option<String>,
    pub track_number: Option<u8>,
    pub genre: Option<u8>,
}
Expand description

An ID3v1 tag

Supported file types

ID3v1 is a severely limited format, with each field being incredibly small in size. All fields have been commented with their maximum sizes and any other additional restrictions.

Attempting to write a field greater than the maximum size will not error, it will just be shrunk.

Conversions

From Tag

Two checks are performed when converting a genre:

Fields§

§title: Option<String>

Track title, 30 bytes max

§artist: Option<String>

Track artist, 30 bytes max

§album: Option<String>

Album title, 30 bytes max

§year: Option<String>

Release year, 4 bytes max

§comment: Option<String>

A short comment

The number of bytes differs between versions, but not much. A V1 tag may have been read, which limits this field to 30 bytes. A V1.1 tag, however, only has 28 bytes available.

Lofty will always write a V1.1 tag.

§track_number: Option<u8>

The track number, 1 byte max

Issues:

  • The track number cannot be 0. Many readers, including Lofty, look for a null byte at the end of the comment to differentiate between V1 and V1.1.
  • A V1 tag may have been read, which does not have a track number.
§genre: Option<u8>

The track’s genre, 1 byte max

ID3v1 has a predefined set of genres, see GENRES. This byte should be an index to a genre.

Implementations§

source§

impl Id3v1Tag

source

pub fn new() -> Self

Create a new empty ID3v1Tag

Examples
use lofty::id3::v1::Id3v1Tag;
use lofty::TagExt;

let id3v1_tag = Id3v1Tag::new();
assert!(id3v1_tag.is_empty());

Trait Implementations§

source§

impl Accessor for Id3v1Tag

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 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 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, genre: String)

Sets the genre Read more
source§

fn remove_genre(&mut self)

Removes the genre 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 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 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§

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§

impl Clone for Id3v1Tag

source§

fn clone(&self) -> Id3v1Tag

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 Id3v1Tag

source§

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

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

impl Default for Id3v1Tag

source§

fn default() -> Id3v1Tag

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

impl From<Id3v1Tag> for Tag

source§

fn from(input: Id3v1Tag) -> Self

Converts to this type from the input type.
source§

impl From<Tag> for Id3v1Tag

source§

fn from(input: Tag) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Id3v1Tag> for Id3v1Tag

source§

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

§

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 Id3v1Tag

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 ItemKey

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(&self, file: &mut File) -> Result<(), Self::Err>

Save the tag to a File 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 Id3v1Tag

source§

impl StructuralEq for Id3v1Tag

source§

impl StructuralPartialEq for Id3v1Tag

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.