pub struct Picture { /* private fields */ }Expand description
Represents a picture.
Implementations
sourceimpl Picture
impl Picture
sourcepub fn from_reader<R>(reader: &mut R) -> Result<Self> where
R: Read,
pub fn from_reader<R>(reader: &mut R) -> Result<Self> where
R: Read,
Create a Picture from a reader
NOTES:
- This 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
sourcepub 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.
sourcepub fn pic_type(&self) -> PictureType
pub fn pic_type(&self) -> PictureType
Returns the PictureType
sourcepub fn set_pic_type(&mut self, pic_type: PictureType)
pub fn set_pic_type(&mut self, pic_type: PictureType)
Sets the PictureType
sourcepub fn mime_type(&self) -> &MimeType
pub fn mime_type(&self) -> &MimeType
Returns the MimeType
The mime_type is determined from the data, and
is immutable.
sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Returns the description
sourcepub fn set_description(&mut self, description: Option<String>)
pub fn set_description(&mut self, description: Option<String>)
Sets the description
sourcepub fn data(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn data(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns the picture data
sourcepub fn as_apic_bytes(
&self,
version: Id3v2Version,
text_encoding: TextEncoding
) -> Result<Vec<u8>>
This is supported on crate feature id3v2 only.
pub fn as_apic_bytes(
&self,
version: Id3v2Version,
text_encoding: TextEncoding
) -> Result<Vec<u8>>
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:
- The mimetype is not
MimeType::PngorMimeType::Jpeg
sourcepub fn from_apic_bytes(
bytes: &[u8],
version: Id3v2Version
) -> Result<(Self, TextEncoding)>
This is supported on crate feature id3v2 only.
pub fn from_apic_bytes(
bytes: &[u8],
version: Id3v2Version
) -> Result<(Self, TextEncoding)>
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”
sourcepub fn as_flac_bytes(
&self,
picture_information: PictureInformation,
encode: bool
) -> Vec<u8>
This is supported on crate feature vorbis_comments only.
pub fn as_flac_bytes(
&self,
picture_information: PictureInformation,
encode: bool
) -> Vec<u8>
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
sourcepub fn from_flac_bytes(
bytes: &[u8],
encoded: bool
) -> Result<(Self, PictureInformation)>
This is supported on crate feature vorbis_comments only.
pub fn from_flac_bytes(
bytes: &[u8],
encoded: bool
) -> Result<(Self, PictureInformation)>
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
sourcepub fn as_ape_bytes(&self) -> Vec<u8>
This is supported on crate feature ape only.
pub fn as_ape_bytes(&self) -> Vec<u8>
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
sourcepub fn from_ape_bytes(key: &str, bytes: &[u8]) -> Result<Self>
This is supported on crate feature ape only.
pub fn from_ape_bytes(key: &str, bytes: &[u8]) -> Result<Self>
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
impl Eq for Picture
impl StructuralEq for Picture
impl StructuralPartialEq for Picture
Auto Trait Implementations
impl RefUnwindSafe for Picture
impl Send for Picture
impl Sync for Picture
impl Unpin for Picture
impl UnwindSafe for Picture
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more