pub struct Picture { /* private fields */ }
Expand description

Represents a picture.

Implementations

Create a Picture from a reader

NOTES:

  • This is for reading picture data only, from a File for example.
  • pic_type will always be PictureType::Other, be sure to change it accordingly if writing.
Errors
  • reader contains less than 8 bytes
  • reader does not contain a supported format. See MimeType for valid formats

Create a new Picture

NOTE: This will not verify data’s signature. This should only be used if all data has been verified beforehand.

Returns the PictureType

Sets the PictureType

Returns the MimeType

The mime_type is determined from the data, and is immutable.

Returns the description

Sets the description

Returns the picture data

This is supported on crate feature id3v2 only.

Convert a Picture to a ID3v2 A/PIC byte Vec

NOTE: This does not include the frame header

Errors
  • Too much data was provided

ID3v2.2:

This is supported on crate feature id3v2 only.

Get a Picture and TextEncoding from ID3v2 A/PIC bytes:

NOTE: This expects only the frame content

Errors
  • There isn’t enough data present
  • The data isn’t a picture

ID3v2.2:

  • The format is not “PNG” or “JPG”
This is supported on crate feature vorbis_comments only.

Convert a Picture to a base64 encoded FLAC METADATA_BLOCK_PICTURE String

Use encode to convert the picture to a base64 encoded String (RFC 4648 §4)

NOTES:

  • This does not include a key (Vorbis comments) or METADATA_BLOCK_HEADER (FLAC blocks)
  • FLAC blocks have different size requirements than OGG Vorbis/Opus, size is not checked here
  • When writing to Vorbis comments, the data must be base64 encoded
This is supported on crate feature vorbis_comments only.

Get a Picture from FLAC METADATA_BLOCK_PICTURE bytes:

NOTE: This takes both the base64 encoded string from Vorbis comments, and the raw data from a FLAC block, specified with encoded.

Errors

This function will return NotAPicture if at any point it’s unable to parse the data

This is supported on crate feature ape only.

Convert a Picture to an APE Cover Art byte vec:

NOTE: This is only the picture data and description, a key and terminating null byte will not be prepended. To map a PictureType to an APE key see PictureType::as_ape_key

This is supported on crate feature ape only.

Get a Picture from an APEv2 binary item:

NOTE: This function expects bytes to contain only the APE item data

Errors

This function will return NotAPicture if at any point it’s unable to parse the data

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.