Struct metaflac::Tag[][src]

pub struct Tag { /* fields omitted */ }
Expand description

A structure representing a flac metadata tag.

Implementations

Creates a new FLAC tag with no blocks.

Adds a block to the tag.

Returns a reference to the blocks in the tag.

Returns references to the blocks with the specified type.

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().count(), 1);

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());

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());

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().collect::<Vec<_>>(), &[&value1, &value2]);

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().collect::<Vec<_>>(), &[&value1, &value2]);

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().collect::<Vec<_>>(), &[&value1, &value2]);

tag.remove_vorbis(&key);
assert!(tag.get_vorbis(&key).is_none());

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().collect::<Vec<_>>(), &[&value1, &value2]);

tag.remove_vorbis_pair(&key, &value1);
assert_eq!(tag.get_vorbis(&key).unwrap().collect::<Vec<_>>(), &[&value2]);

Returns an iterator 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().count(), 0);
tag.add_picture("image/jpeg", CoverFront, vec!(0xFF));
assert_eq!(tag.pictures().count(), 1);

Adds a picture block.

Example
use metaflac::Tag;
use metaflac::block::PictureType::CoverFront;

let mut tag = Tag::new();
assert_eq!(tag.pictures().count(), 0);

tag.add_picture("image/jpeg", CoverFront, vec!(0xFF));

let picture = tag.pictures().next().unwrap();
assert_eq!(&picture.mime_type, "image/jpeg");
assert_eq!(picture.picture_type, CoverFront);
assert_eq!(&picture.data, &vec!(0xFF));

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().count(), 0);

tag.add_picture("image/jpeg", CoverFront, vec!(0xFF));
tag.add_picture("image/png", Other, vec!(0xAB));
assert_eq!(tag.pictures().count(), 2);

tag.remove_picture_type(CoverFront);
assert_eq!(tag.pictures().count(), 1);

let picture = tag.pictures().next().unwrap();
assert_eq!(&picture.mime_type, "image/png");
assert_eq!(picture.picture_type, Other);
assert_eq!(&picture.data, &vec!(0xAB));

Returns a reference to the first streaminfo block. Returns None if no streaminfo blocks are found.

Example
use metaflac::Tag;
use metaflac::block::StreamInfo;

let mut tag = Tag::new();
assert!(tag.get_streaminfo().is_none());
tag.set_streaminfo(StreamInfo::new());
assert!(tag.get_streaminfo().is_some());

Sets the streaminfo block. If there is already a streaminfo block then it will be replaced.

Example
use metaflac::Tag;
use metaflac::block::StreamInfo;

let mut tag = Tag::new();
tag.set_streaminfo(StreamInfo::new());
assert!(tag.get_streaminfo().is_some());

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.

Returns the contents of the reader without any FLAC metadata.

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.

Attempts to read a FLAC tag from the reader.

Attempts to write the FLAC tag to the writer.

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.

Attempts to read a FLAC tag from the file at the specified path.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.