Struct metaflac::Tag [] [src]

pub struct Tag { /* fields omitted */ }

A structure representing a flac metadata tag.

Methods

impl Tag
[src]

[src]

Creates a new FLAC tag with no blocks.

[src]

Adds a block to the tag.

[src]

Returns a reference to the blocks in the tag.

[src]

Returns references to the blocks with the specified type.

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

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

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

[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[..]]);

[src]

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[..]]);

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

[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[..]]);

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

[src]

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)[..]);

[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)[..]);

[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.

[src]

Returns the contents of the reader without any FLAC metadata.

[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.

[src]

Attempts to read a FLAC tag from the reader.

[src]

Attempts to write the FLAC tag to the wrier.

[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.

[src]

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

Trait Implementations

impl Clone for Tag
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more