Struct lofty::Picture [−][src]
pub struct Picture { /* fields omitted */ }Expand description
Represents a picture.
Implementations
Create a Picture from a reader
NOTES:
- This is not for reading format-specific
pictures, it is for reading picture data only,
from a
Filefor example. pic_typewill always bePictureType::Other, be sure to change it accordingly if writing.
Errors
readercontains less than 8 bytesreaderdoes not contain a supported format. SeeMimeTypefor valid formats
pub fn new_unchecked(
pic_type: PictureType,
mime_type: MimeType,
description: Option<String>,
data: Vec<u8>
) -> Self
pub fn new_unchecked(
pic_type: PictureType,
mime_type: MimeType,
description: Option<String>,
data: Vec<u8>
) -> Self
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
pub fn as_apic_bytes(
&self,
version: Id3v2Version,
text_encoding: TextEncoding
) -> Result<Vec<u8>>
pub fn as_apic_bytes(
&self,
version: Id3v2Version,
text_encoding: TextEncoding
) -> Result<Vec<u8>>
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:
- The mimetype is not
MimeType::PngorMimeType::Jpeg
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”
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
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.
Errors
This function will return NotAPicture if
at any point it’s unable to parse the data
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
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
Auto Trait Implementations
impl RefUnwindSafe for Picture
impl UnwindSafe for Picture
Blanket Implementations
Mutably borrows from an owned value. Read more
