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
and22
. All other integer types will be stored asAtomData::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.
Implementations§
Source§impl AtomData
impl AtomData
Sourcepub fn data_type(&self) -> DataType
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);