pub trait OggPictureStorage: Sealed {
    // Required method
    fn pictures(&self) -> &[(Picture, PictureInformation)];

    // Provided methods
    fn insert_picture(
        &mut self,
        picture: Picture,
        information: Option<PictureInformation>
    ) -> Result<Option<(Picture, PictureInformation)>> { ... }
    fn remove_picture_type(&mut self, picture_type: PictureType) { ... }
    fn set_picture(
        &mut self,
        index: usize,
        picture: Picture,
        info: PictureInformation
    ) { ... }
    fn remove_picture(&mut self, index: usize) -> (Picture, PictureInformation) { ... }
    fn remove_pictures(&mut self) -> Vec<(Picture, PictureInformation)> { ... }
}
Expand description

Defines methods for interacting with an item storing OGG pictures

This exists due to both VorbisComments and FlacFile needing to store pictures in their own ways.

It cannot be implemented downstream.

Required Methods§

source

fn pictures(&self) -> &[(Picture, PictureInformation)]

Returns the stored Pictures as a slice

Examples
use lofty::ogg::{OggPictureStorage, VorbisComments};

let mut tag = VorbisComments::default();

assert!(tag.pictures().is_empty());

Provided Methods§

source

fn insert_picture( &mut self, picture: Picture, information: Option<PictureInformation> ) -> Result<Option<(Picture, PictureInformation)>>

Inserts a Picture

NOTES:

Errors
source

fn remove_picture_type(&mut self, picture_type: PictureType)

Removes a certain PictureType

source

fn set_picture( &mut self, index: usize, picture: Picture, info: PictureInformation )

Replaces the picture at the given index

NOTE: If index is out of bounds, the picture will be appended to the list.

Examples
use lofty::ogg::{VorbisComments, OggPictureStorage};

let mut tag = VorbisComments::default();

// Add a front cover
tag.insert_picture(front_cover, Some(front_cover_info))?;

assert_eq!(tag.pictures().len(), 1);
assert_eq!(tag.pictures()[0].0.pic_type(), PictureType::CoverFront);

// Replace the front cover with a back cover
tag.set_picture(0, back_cover, back_cover_info);

assert_eq!(tag.pictures().len(), 1);
assert_eq!(tag.pictures()[0].0.pic_type(), PictureType::CoverBack);

// Use an out of bounds index
tag.set_picture(100, another_picture, PictureInformation::default());

assert_eq!(tag.pictures().len(), 2);
source

fn remove_picture(&mut self, index: usize) -> (Picture, PictureInformation)

Removes and returns the picture at the given index

Panics

Panics if index is out of bounds.

Examples
use lofty::ogg::{VorbisComments, OggPictureStorage};

let mut tag = VorbisComments::default();

// Add a front cover
tag.insert_picture(front_cover, Some(front_cover_info))?;

assert_eq!(tag.pictures().len(), 1);

tag.remove_picture(0);

assert_eq!(tag.pictures().len(), 0);
source

fn remove_pictures(&mut self) -> Vec<(Picture, PictureInformation)>

Removes all pictures and returns them

Examples
use lofty::ogg::{VorbisComments, OggPictureStorage};

let mut tag = VorbisComments::default();

// Add front and back covers
tag.insert_picture(front_cover, Some(front_cover_info))?;
tag.insert_picture(back_cover, Some(front_cover_info))?;

assert_eq!(tag.pictures().len(), 2);

let pictures = tag.remove_pictures();
assert_eq!(pictures.len(), 2);

// The tag no longer contains any pictures
assert_eq!(tag.pictures().len(), 0);

Implementors§