pub struct Picture { /* private fields */ }Expand description
Represents a picture.
Implementations§
source§impl 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: Option<MimeType>,
description: Option<String>,
data: Vec<u8>,
) -> Self
pub fn new_unchecked( pic_type: PictureType, mime_type: Option<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) -> Option<&MimeType>
pub fn mime_type(&self) -> Option<&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 as_flac_bytes(
&self,
picture_information: PictureInformation,
encode: bool,
) -> Vec<u8>
pub fn as_flac_bytes( &self, picture_information: PictureInformation, encode: bool, ) -> Vec<u8>
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,
parse_mode: ParsingMode,
) -> Result<(Self, PictureInformation)>
pub fn from_flac_bytes( bytes: &[u8], encoded: bool, parse_mode: ParsingMode, ) -> Result<(Self, PictureInformation)>
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>
pub fn as_ape_bytes(&self) -> Vec<u8>
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>
pub fn from_ape_bytes(key: &str, bytes: &[u8]) -> Result<Self>
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§
source§impl PartialEq for Picture
impl PartialEq for Picture
impl Eq for Picture
impl StructuralPartialEq for Picture
Auto Trait Implementations§
impl Freeze for Picture
impl RefUnwindSafe for Picture
impl Send for Picture
impl Sync for Picture
impl Unpin for Picture
impl UnwindSafe for Picture
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)