Enum Data

Source
pub enum Data {
    Reserved(Vec<u8>),
    Utf8(String),
    Utf16(String),
    Jpeg(Vec<u8>),
    Png(Vec<u8>),
    Bmp(Vec<u8>),
    BeSigned(Vec<u8>),
    Unknown {
        code: u32,
        data: Vec<u8>,
    },
}
Expand description

Different types of data defined by Table 3-5 Well-known data types.

Variants§

§

Reserved(Vec<u8>)

Reserved for use where no type needs to be indicated. This is often used for track/disc numbers and standard genre codes.

§

Utf8(String)

A utf-8 encoded string.

§

Utf16(String)

A utf-16 encoded string.

§

Jpeg(Vec<u8>)

A JPEG image. Note that this type is more of a hint and many encoders use any of the image formats for all kinds of image data.

§

Png(Vec<u8>)

A PNG image. Note that this type is more of a hint and many encoders use any of the image formats for all kinds of image data.

§

Bmp(Vec<u8>)

A BMP image. Note that this type is more of a hint and many encoders use any of the image formats for all kinds of image data.

§

BeSigned(Vec<u8>)

A big-endian signed integer. This is often used for track/disc numbers and standard genre codes.

§

Unknown

A value containing an unknown data type code and data.

Fields

§code: u32

The data type code.

§data: Vec<u8>

The data.

Implementations§

Source§

impl Data

Source

pub fn parse( reader: &mut (impl Read + Seek), cfg: &ParseConfig<'_>, size: Size, ) -> Result<Data>

Parses data based on Table 3-5 Well-known data types.

Source

pub fn write(&self, writer: &mut impl Write) -> Result<()>

Source

pub fn len(&self) -> u64

Source§

impl Data

Source

pub fn data_len(&self) -> u64

Returns the length of the raw data (without version, datatype and locale header) in bytes.

Source

pub fn is_empty(&self) -> bool

Returns true if the data is of length 0, false otherwise.

Source

pub const fn is_bytes(&self) -> bool

Returns true if the data is of type Reserved or BeSigned.

Source

pub const fn is_string(&self) -> bool

Returns true if the data is of type Utf8 or Utf16.

Source

pub const fn is_image(&self) -> bool

Returns true if the data is of type Jpeg, Png or Bmp.

Source

pub const fn is_reserved(&self) -> bool

Returns true if the data is of type Reserved.

Source

pub const fn is_utf8(&self) -> bool

Returns true if the data is of type Utf8.

Source

pub const fn is_utf16(&self) -> bool

Returns true if the data is of type Utf16.

Source

pub const fn is_jpeg(&self) -> bool

Returns true if the data is of type Jpeg.

Source

pub const fn is_png(&self) -> bool

Returns true if the data is of type Png.

Source

pub const fn is_bmp(&self) -> bool

Returns true if the data is of type Bmp.

Source

pub const fn is_be_signed(&self) -> bool

Returns true if the data is of type BeSigned.

Source

pub fn bytes(&self) -> Option<&[u8]>

Returns a byte reference if the data is of type Reserved or BeSigned.

Source

pub fn bytes_mut(&mut self) -> Option<&mut Vec<u8>>

Returns a mutable byte reference if the data is of type Reserved or BeSigned.

Source

pub fn into_bytes(self) -> Option<Vec<u8>>

Returns the owned bytes if the data is of type Reserved or BeSigned.

Source

pub fn string(&self) -> Option<&str>

Returns a string reference if the data is of type Utf8 or Utf16.

Source

pub fn string_mut(&mut self) -> Option<&mut String>

Returns a mutable string reference if the data is of type Utf8 or Utf16.

Source

pub fn into_string(self) -> Option<String>

Returns the owned string if the data is of type Utf8 or Utf16.

Source

pub fn image(&self) -> Option<ImgRef<'_>>

Returns an image reference the data is of type Jpeg, Png or Bmp.

Source

pub fn image_mut(&mut self) -> Option<ImgMut<'_>>

Returns a mutable image reference if the data is of type Jpeg, Png or Bmp.

Source

pub fn into_image(self) -> Option<ImgBuf>

Returns the owned image if the data is of type Jpeg, Png or Bmp.

Source

pub fn image_data(&self) -> Option<&[u8]>

Returns an image data reference if the data is of type Jpeg, Png or Bmp.

Source

pub fn image_data_mut(&mut self) -> Option<&mut Vec<u8>>

Returns a mutable image data reference if the data is of type Jpeg, Png or Bmp.

Source

pub fn into_image_data(self) -> Option<Vec<u8>>

Returns the owned image data if the data is of type Jpeg, Png or Bmp.

Source

pub fn reserved(&self) -> Option<&[u8]>

Returns a byte reference if the data is of type Reserved.

Source

pub fn utf8(&self) -> Option<&str>

Returns a string reference if the data is of type Utf8.

Source

pub fn utf16(&self) -> Option<&str>

Returns a string reference if the data is of type Utf16.

Source

pub fn jpeg(&self) -> Option<&[u8]>

Returns an image data reference data if the data is of type Jpeg.

Source

pub fn png(&self) -> Option<&[u8]>

Returns an image data reference if the data is of type Png.

Source

pub fn bmp(&self) -> Option<&[u8]>

Returns an image data reference if the data is of type Bmp.

Source

pub fn be_signed(&self) -> Option<&[u8]>

Returns a byte reference if the data is of type BeSigned.

Trait Implementations§

Source§

impl Clone for Data

Source§

fn clone(&self) -> Data

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 Data

Source§

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

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

impl<T: Into<Vec<u8>>> From<Img<T>> for Data

Source§

fn from(image: Img<T>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Data

Source§

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

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

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 Data

Source§

impl StructuralPartialEq for Data

Auto Trait Implementations§

§

impl Freeze for Data

§

impl RefUnwindSafe for Data

§

impl Send for Data

§

impl Sync for Data

§

impl Unpin for Data

§

impl UnwindSafe for Data

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, dst: *mut u8)

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