Enum AtomData

Source
pub enum AtomData {
    UTF8(String),
    UTF16(String),
    Picture(Picture),
    SignedInteger(i32),
    UnsignedInteger(u32),
    Bool(bool),
    Unknown {
        code: DataType,
        data: Vec<u8>,
    },
}
Expand description

The data of an atom

NOTES:

  • This only covers the most common data types. See the list of DataType for all known types.
  • There are only two variants for integers, which will come from codes 21 and 22. All other integer types will be stored as AtomData::Unknown, refer to the link above for codes.

Variants§

§

UTF8(String)

A UTF-8 encoded string

§

UTF16(String)

A UTF-16 encoded string

§

Picture(Picture)

A JPEG, PNG, GIF (Deprecated), or BMP image

The type is read from the picture itself

§

SignedInteger(i32)

A big endian signed integer (1-4 bytes)

NOTE:

This will shrink the integer when writing

255 will be written as [255] rather than [0, 0, 0, 255]

This behavior may be unexpected, use AtomData::Unknown if unsure

§

UnsignedInteger(u32)

A big endian unsigned integer (1-4 bytes)

NOTE: See AtomData::SignedInteger

§

Bool(bool)

A boolean value

NOTE: This isn’t an official data type, but multiple flag atoms exist, so this makes them easier to represent. The real underlying type is Self::SignedInteger.

§

Unknown

Unknown data

Due to the number of possible types, there are many specified types that are going to fall into this variant. See DataType for a list of known types.

Fields

§code: DataType

The code, or type of the item

§data: Vec<u8>

The binary data of the atom

Implementations§

Source§

impl AtomData

Source

pub fn data_type(&self) -> DataType

Get the DataType of the atom

Note that for AtomData::Picture, the type is determined by the picture’s MIME type. If the MIME type is unknown (or unset), the data type will be DataType::Reserved.

§Examples
use lofty::mp4::{AtomData, DataType};
use lofty::picture::{MimeType, Picture, PictureType};

let data = AtomData::UTF8(String::from("foo"));
assert_eq!(data.data_type(), DataType::Utf8);

let data = AtomData::SignedInteger(42);
assert_eq!(data.data_type(), DataType::BeSignedInteger);

let data = AtomData::Picture(Picture::new_unchecked(
	PictureType::CoverFront,
	Some(MimeType::Jpeg),
	None,
	Vec::new(),
));
assert_eq!(data.data_type(), DataType::Jpeg);

Trait Implementations§

Source§

impl Clone for AtomData

Source§

fn clone(&self) -> AtomData

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 AtomData

Source§

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

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

impl PartialEq for AtomData

Source§

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

Source§

impl StructuralPartialEq for AtomData

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.