Struct 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

§To Tag

All fields can be translated to a TagItem:

§From Tag

All of the ItemKeys referenced in the conversion to Tag will be checked.

The values will be used as-is, with two exceptions:

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::tag::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 duplicate of the value. Read more
1.0.0 · Source§

const 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 for Id3v1Tag

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SplitTag for Id3v1Tag

Source§

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, write_options: WriteOptions, ) -> Result<(), Self::Err>

Dumps the tag to a writer

§Errors
Source§

type Err = LoftyError

The associated error which can be returned from IO operations
Source§

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<F>( &self, file: &mut F, write_options: WriteOptions, ) -> Result<(), Self::Err>
where F: FileLike, LoftyError: From<<F as Truncate>::Error> + From<<F as Length>::Error>,

Save the tag to a FileLike 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<F>(&self, file: &mut F) -> Result<(), Self::Err>
where F: FileLike, LoftyError: From<<F as Truncate>::Error> + From<<F as Length>::Error>,

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

Save the tag to a path Read more
Source§

impl Eq for Id3v1Tag

Source§

impl StructuralPartialEq for Id3v1Tag

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

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

Source§

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.