Struct metaflac::Tag
[−]
[src]
pub struct Tag { /* fields omitted */ }
A structure representing a flac metadata tag.
Methods
impl Tag
[src]
fn new() -> Tag
[src]
Creates a new FLAC tag with no blocks.
fn push_block(&mut self, block: Block)
[src]
Adds a block to the tag.
fn blocks(&self) -> &Vec<Block>
[src]
Returns a reference to the blocks in the tag.
fn get_blocks(&self, block_type: BlockType) -> Vec<&Block>
[src]
Returns references to the blocks with the specified type.
fn remove_blocks(&mut self, block_type: BlockType)
[src]
Removes blocks with the specified type.
Example
use metaflac::{Tag, Block, BlockType}; let mut tag = Tag::new(); tag.push_block(Block::Padding(10)); tag.push_block(Block::Unknown((20, Vec::new()))); tag.push_block(Block::Padding(15)); tag.remove_blocks(BlockType::Padding); assert_eq!(tag.blocks().len(), 1);
fn vorbis_comments(&self) -> Option<&VorbisComment>
[src]
Returns a reference to the first vorbis comment block.
Returns None
if no vorbis comment blocks are found.
Example
use metaflac::Tag; let mut tag = Tag::new(); assert!(tag.vorbis_comments().is_none()); tag.set_vorbis("key", vec!("value")); assert!(tag.vorbis_comments().is_some());
fn vorbis_comments_mut(&mut self) -> &mut VorbisComment
[src]
Returns a mutable reference to the first vorbis comment block. If no block is found, a new vorbis comment block is added to the tag and a reference to the newly added block is returned.
Example
use metaflac::Tag; let mut tag = Tag::new(); assert!(tag.vorbis_comments().is_none()); let key = "key".to_owned(); let value1 = "value1".to_owned(); let value2 = "value2".to_owned(); tag.vorbis_comments_mut().comments.insert(key.clone(), vec!(value1.clone(), value2.clone())); assert!(tag.vorbis_comments().is_some()); assert!(tag.vorbis_comments().unwrap().comments.get(&key).is_some());
fn get_vorbis(&self, key: &str) -> Option<&Vec<String>>
[src]
Returns a vector of strings values for the specified vorbis comment key.
Returns None
if the tag does not contain a vorbis comment or if the vorbis comment does
not contain a comment with the specified key.
Example
use metaflac::Tag; let mut tag = Tag::new(); let key = "key".to_owned(); let value1 = "value1".to_owned(); let value2 = "value2".to_owned(); tag.set_vorbis(&key[..], vec!(&value1[..], &value2[..])); assert_eq!(&tag.get_vorbis(&key).unwrap()[..], &[&value1[..], &value2[..]]);
fn set_vorbis<K: Into<String>, V: Into<String>>(
&mut self,
key: K,
values: Vec<V>
)
[src]
&mut self,
key: K,
values: Vec<V>
)
Sets the values for the specified vorbis comment key.
Example
use metaflac::Tag; let mut tag = Tag::new(); let key = "key".to_owned(); let value1 = "value1".to_owned(); let value2 = "value2".to_owned(); tag.set_vorbis(&key[..], vec!(&value1[..], &value2[..])); assert_eq!(&tag.get_vorbis(&key).unwrap()[..], &[&value1[..], &value2[..]]);
fn remove_vorbis(&mut self, key: &str)
[src]
Removes the values for the specified vorbis comment key.
Example
use metaflac::Tag; let mut tag = Tag::new(); let key = "key".to_owned(); let value1 = "value1".to_owned(); let value2 = "value2".to_owned(); tag.set_vorbis(&key[..], vec!(&value1[..], &value2[..])); assert_eq!(&tag.get_vorbis(&key).unwrap()[..], &[&value1[..], &value2[..]]); tag.remove_vorbis(&key); assert!(tag.get_vorbis(&key).is_none());
fn remove_vorbis_pair(&mut self, key: &str, value: &str)
[src]
Removes the vorbis comments with the specified key and value.
Example
use metaflac::Tag; let mut tag = Tag::new(); let key = "key".to_owned(); let value1 = "value1".to_owned(); let value2 = "value2".to_owned(); tag.set_vorbis(key.clone(), vec!(&value1[..], &value2[..])); assert_eq!(&tag.get_vorbis(&key).unwrap()[..], &[&value1[..], &value2[..]]); tag.remove_vorbis_pair(&key, &value1); assert_eq!(&tag.get_vorbis(&key).unwrap()[..], &[&value2[..]]);
fn pictures(&self) -> Vec<&Picture>
[src]
Returns a vector of references to the pictures in the tag.
Example
use metaflac::Tag; use metaflac::block::PictureType::CoverFront; let mut tag = Tag::new(); assert_eq!(tag.pictures().len(), 0); tag.add_picture("image/jpeg", CoverFront, vec!(0xFF)); assert_eq!(tag.pictures().len(), 1);
fn add_picture<T: Into<String>>(
&mut self,
mime_type: T,
picture_type: PictureType,
data: Vec<u8>
)
[src]
&mut self,
mime_type: T,
picture_type: PictureType,
data: Vec<u8>
)
Adds a picture block.
Example
use metaflac::Tag; use metaflac::block::PictureType::CoverFront; let mut tag = Tag::new(); assert_eq!(tag.pictures().len(), 0); tag.add_picture("image/jpeg", CoverFront, vec!(0xFF)); assert_eq!(&tag.pictures()[0].mime_type[..], "image/jpeg"); assert_eq!(tag.pictures()[0].picture_type, CoverFront); assert_eq!(&tag.pictures()[0].data[..], &vec!(0xFF)[..]);
fn remove_picture_type(&mut self, picture_type: PictureType)
[src]
Removes the picture with the specified picture type.
Example
use metaflac::Tag; use metaflac::block::PictureType::{CoverFront, Other}; let mut tag = Tag::new(); assert_eq!(tag.pictures().len(), 0); tag.add_picture("image/jpeg", CoverFront, vec!(0xFF)); tag.add_picture("image/png", Other, vec!(0xAB)); assert_eq!(tag.pictures().len(), 2); tag.remove_picture_type(CoverFront); assert_eq!(tag.pictures().len(), 1); assert_eq!(&tag.pictures()[0].mime_type[..], "image/png"); assert_eq!(tag.pictures()[0].picture_type, Other); assert_eq!(&tag.pictures()[0].data[..], &vec!(0xAB)[..]);
fn save(&mut self) -> Result<()>
[src]
Attempts to save the tag back to the file which it was read from. An Error::InvalidInput
will be returned if this is called on a tag which was not read from a file.
fn skip_metadata<R: Read + Seek>(reader: &mut R) -> Vec<u8>
[src]
Returns the contents of the reader without any FLAC metadata.
fn is_candidate<R: Read + Seek>(reader: &mut R) -> bool
[src]
Will return true if the reader is a candidate for FLAC metadata. The reader position will be reset back to the previous position before returning.
fn read_from(reader: &mut Read) -> Result<Tag>
[src]
Attempts to read a FLAC tag from the reader.
fn write_to(&mut self, writer: &mut Write) -> Result<()>
[src]
Attempts to write the FLAC tag to the wrier.
fn write_to_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
[src]
Attempts to write the FLAC tag to a file at the indicated path. If the specified path is the same path which the tag was read from, then the tag will be written to the padding if possible.
fn read_from_path<P: AsRef<Path>>(path: P) -> Result<Tag>
[src]
Attempts to read a FLAC tag from the file at the specified path.