pub struct Tag<'a> { /* private fields */ }
Expand description
The abstract meta-data container for audio files
Each Tag
instance can only be created by the taglib::File::tag()
method.
Implementations§
Source§impl<'a> Tag<'a>
impl<'a> Tag<'a>
Sourcepub fn title(&self) -> Option<String>
pub fn title(&self) -> Option<String>
Returns the track name, if any.
Examples found in repository?
examples/tagreader.rs (line 23)
5pub fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 for i in 1..args.len() {
9 let ref arg = args[i];
10 let file = match taglib::File::new(arg) {
11 Ok(f) => f,
12 Err(e) => {
13 println!("Invalid file {} (error: {:?})", arg, e);
14 continue;
15 }
16 };
17
18 println!("*** \"{}\" ***", arg);
19
20 match file.tag() {
21 Ok(t) => {
22 println!("-- TAG --");
23 println!("title - {}", t.title().unwrap_or_default());
24 println!("artist - {}", t.artist().unwrap_or_default());
25 println!("album - {}", t.album().unwrap_or_default());
26 println!("year - {}", t.year().unwrap_or_default());
27 println!("comment - {}", t.comment().unwrap_or_default());
28 println!("track - {}", t.track().unwrap_or_default());
29 println!("genre - {}", t.genre().unwrap_or_default());
30 }
31 Err(e) => {
32 println!("No available tags for {} (error: {:?})", arg, e);
33 }
34 }
35
36 match file.audioproperties() {
37 Ok(p) => {
38 let secs = p.length() % 60;
39 let mins = (p.length() - secs) / 60;
40
41 println!("-- AUDIO --");
42 println!("bitrate - {}", p.bitrate());
43 println!("sample rate - {}", p.samplerate());
44 println!("channels - {}", p.channels());
45 println!("length - {}m:{}s", mins, secs);
46 }
47 Err(e) => {
48 println!("No available audio properties for {} (error: {:?})", arg, e);
49 }
50 }
51 }
52}
Sourcepub fn artist(&self) -> Option<String>
pub fn artist(&self) -> Option<String>
Returns the artist name, if any.
Examples found in repository?
examples/tagreader.rs (line 24)
5pub fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 for i in 1..args.len() {
9 let ref arg = args[i];
10 let file = match taglib::File::new(arg) {
11 Ok(f) => f,
12 Err(e) => {
13 println!("Invalid file {} (error: {:?})", arg, e);
14 continue;
15 }
16 };
17
18 println!("*** \"{}\" ***", arg);
19
20 match file.tag() {
21 Ok(t) => {
22 println!("-- TAG --");
23 println!("title - {}", t.title().unwrap_or_default());
24 println!("artist - {}", t.artist().unwrap_or_default());
25 println!("album - {}", t.album().unwrap_or_default());
26 println!("year - {}", t.year().unwrap_or_default());
27 println!("comment - {}", t.comment().unwrap_or_default());
28 println!("track - {}", t.track().unwrap_or_default());
29 println!("genre - {}", t.genre().unwrap_or_default());
30 }
31 Err(e) => {
32 println!("No available tags for {} (error: {:?})", arg, e);
33 }
34 }
35
36 match file.audioproperties() {
37 Ok(p) => {
38 let secs = p.length() % 60;
39 let mins = (p.length() - secs) / 60;
40
41 println!("-- AUDIO --");
42 println!("bitrate - {}", p.bitrate());
43 println!("sample rate - {}", p.samplerate());
44 println!("channels - {}", p.channels());
45 println!("length - {}m:{}s", mins, secs);
46 }
47 Err(e) => {
48 println!("No available audio properties for {} (error: {:?})", arg, e);
49 }
50 }
51 }
52}
Sourcepub fn set_artist(&mut self, artist: &str)
pub fn set_artist(&mut self, artist: &str)
Sets the artist name.
Sourcepub fn album(&self) -> Option<String>
pub fn album(&self) -> Option<String>
Returns the album name, if any.
Examples found in repository?
examples/tagreader.rs (line 25)
5pub fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 for i in 1..args.len() {
9 let ref arg = args[i];
10 let file = match taglib::File::new(arg) {
11 Ok(f) => f,
12 Err(e) => {
13 println!("Invalid file {} (error: {:?})", arg, e);
14 continue;
15 }
16 };
17
18 println!("*** \"{}\" ***", arg);
19
20 match file.tag() {
21 Ok(t) => {
22 println!("-- TAG --");
23 println!("title - {}", t.title().unwrap_or_default());
24 println!("artist - {}", t.artist().unwrap_or_default());
25 println!("album - {}", t.album().unwrap_or_default());
26 println!("year - {}", t.year().unwrap_or_default());
27 println!("comment - {}", t.comment().unwrap_or_default());
28 println!("track - {}", t.track().unwrap_or_default());
29 println!("genre - {}", t.genre().unwrap_or_default());
30 }
31 Err(e) => {
32 println!("No available tags for {} (error: {:?})", arg, e);
33 }
34 }
35
36 match file.audioproperties() {
37 Ok(p) => {
38 let secs = p.length() % 60;
39 let mins = (p.length() - secs) / 60;
40
41 println!("-- AUDIO --");
42 println!("bitrate - {}", p.bitrate());
43 println!("sample rate - {}", p.samplerate());
44 println!("channels - {}", p.channels());
45 println!("length - {}m:{}s", mins, secs);
46 }
47 Err(e) => {
48 println!("No available audio properties for {} (error: {:?})", arg, e);
49 }
50 }
51 }
52}
Sourcepub fn comment(&self) -> Option<String>
pub fn comment(&self) -> Option<String>
Returns the track comment, if any.
Examples found in repository?
examples/tagreader.rs (line 27)
5pub fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 for i in 1..args.len() {
9 let ref arg = args[i];
10 let file = match taglib::File::new(arg) {
11 Ok(f) => f,
12 Err(e) => {
13 println!("Invalid file {} (error: {:?})", arg, e);
14 continue;
15 }
16 };
17
18 println!("*** \"{}\" ***", arg);
19
20 match file.tag() {
21 Ok(t) => {
22 println!("-- TAG --");
23 println!("title - {}", t.title().unwrap_or_default());
24 println!("artist - {}", t.artist().unwrap_or_default());
25 println!("album - {}", t.album().unwrap_or_default());
26 println!("year - {}", t.year().unwrap_or_default());
27 println!("comment - {}", t.comment().unwrap_or_default());
28 println!("track - {}", t.track().unwrap_or_default());
29 println!("genre - {}", t.genre().unwrap_or_default());
30 }
31 Err(e) => {
32 println!("No available tags for {} (error: {:?})", arg, e);
33 }
34 }
35
36 match file.audioproperties() {
37 Ok(p) => {
38 let secs = p.length() % 60;
39 let mins = (p.length() - secs) / 60;
40
41 println!("-- AUDIO --");
42 println!("bitrate - {}", p.bitrate());
43 println!("sample rate - {}", p.samplerate());
44 println!("channels - {}", p.channels());
45 println!("length - {}m:{}s", mins, secs);
46 }
47 Err(e) => {
48 println!("No available audio properties for {} (error: {:?})", arg, e);
49 }
50 }
51 }
52}
Sourcepub fn set_comment(&mut self, comment: &str)
pub fn set_comment(&mut self, comment: &str)
Sets the track comment.
Sourcepub fn genre(&self) -> Option<String>
pub fn genre(&self) -> Option<String>
Returns the genre name, if any.
Examples found in repository?
examples/tagreader.rs (line 29)
5pub fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 for i in 1..args.len() {
9 let ref arg = args[i];
10 let file = match taglib::File::new(arg) {
11 Ok(f) => f,
12 Err(e) => {
13 println!("Invalid file {} (error: {:?})", arg, e);
14 continue;
15 }
16 };
17
18 println!("*** \"{}\" ***", arg);
19
20 match file.tag() {
21 Ok(t) => {
22 println!("-- TAG --");
23 println!("title - {}", t.title().unwrap_or_default());
24 println!("artist - {}", t.artist().unwrap_or_default());
25 println!("album - {}", t.album().unwrap_or_default());
26 println!("year - {}", t.year().unwrap_or_default());
27 println!("comment - {}", t.comment().unwrap_or_default());
28 println!("track - {}", t.track().unwrap_or_default());
29 println!("genre - {}", t.genre().unwrap_or_default());
30 }
31 Err(e) => {
32 println!("No available tags for {} (error: {:?})", arg, e);
33 }
34 }
35
36 match file.audioproperties() {
37 Ok(p) => {
38 let secs = p.length() % 60;
39 let mins = (p.length() - secs) / 60;
40
41 println!("-- AUDIO --");
42 println!("bitrate - {}", p.bitrate());
43 println!("sample rate - {}", p.samplerate());
44 println!("channels - {}", p.channels());
45 println!("length - {}m:{}s", mins, secs);
46 }
47 Err(e) => {
48 println!("No available audio properties for {} (error: {:?})", arg, e);
49 }
50 }
51 }
52}
Sourcepub fn year(&self) -> Option<u32>
pub fn year(&self) -> Option<u32>
Returns the year, if any.
Examples found in repository?
examples/tagreader.rs (line 26)
5pub fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 for i in 1..args.len() {
9 let ref arg = args[i];
10 let file = match taglib::File::new(arg) {
11 Ok(f) => f,
12 Err(e) => {
13 println!("Invalid file {} (error: {:?})", arg, e);
14 continue;
15 }
16 };
17
18 println!("*** \"{}\" ***", arg);
19
20 match file.tag() {
21 Ok(t) => {
22 println!("-- TAG --");
23 println!("title - {}", t.title().unwrap_or_default());
24 println!("artist - {}", t.artist().unwrap_or_default());
25 println!("album - {}", t.album().unwrap_or_default());
26 println!("year - {}", t.year().unwrap_or_default());
27 println!("comment - {}", t.comment().unwrap_or_default());
28 println!("track - {}", t.track().unwrap_or_default());
29 println!("genre - {}", t.genre().unwrap_or_default());
30 }
31 Err(e) => {
32 println!("No available tags for {} (error: {:?})", arg, e);
33 }
34 }
35
36 match file.audioproperties() {
37 Ok(p) => {
38 let secs = p.length() % 60;
39 let mins = (p.length() - secs) / 60;
40
41 println!("-- AUDIO --");
42 println!("bitrate - {}", p.bitrate());
43 println!("sample rate - {}", p.samplerate());
44 println!("channels - {}", p.channels());
45 println!("length - {}m:{}s", mins, secs);
46 }
47 Err(e) => {
48 println!("No available audio properties for {} (error: {:?})", arg, e);
49 }
50 }
51 }
52}
Sourcepub fn track(&self) -> Option<u32>
pub fn track(&self) -> Option<u32>
Returns the track number, if any.
Examples found in repository?
examples/tagreader.rs (line 28)
5pub fn main() {
6 let args: Vec<String> = env::args().collect();
7
8 for i in 1..args.len() {
9 let ref arg = args[i];
10 let file = match taglib::File::new(arg) {
11 Ok(f) => f,
12 Err(e) => {
13 println!("Invalid file {} (error: {:?})", arg, e);
14 continue;
15 }
16 };
17
18 println!("*** \"{}\" ***", arg);
19
20 match file.tag() {
21 Ok(t) => {
22 println!("-- TAG --");
23 println!("title - {}", t.title().unwrap_or_default());
24 println!("artist - {}", t.artist().unwrap_or_default());
25 println!("album - {}", t.album().unwrap_or_default());
26 println!("year - {}", t.year().unwrap_or_default());
27 println!("comment - {}", t.comment().unwrap_or_default());
28 println!("track - {}", t.track().unwrap_or_default());
29 println!("genre - {}", t.genre().unwrap_or_default());
30 }
31 Err(e) => {
32 println!("No available tags for {} (error: {:?})", arg, e);
33 }
34 }
35
36 match file.audioproperties() {
37 Ok(p) => {
38 let secs = p.length() % 60;
39 let mins = (p.length() - secs) / 60;
40
41 println!("-- AUDIO --");
42 println!("bitrate - {}", p.bitrate());
43 println!("sample rate - {}", p.samplerate());
44 println!("channels - {}", p.channels());
45 println!("length - {}m:{}s", mins, secs);
46 }
47 Err(e) => {
48 println!("No available audio properties for {} (error: {:?})", arg, e);
49 }
50 }
51 }
52}
Auto Trait Implementations§
impl<'a> Freeze for Tag<'a>
impl<'a> RefUnwindSafe for Tag<'a>
impl<'a> !Send for Tag<'a>
impl<'a> !Sync for Tag<'a>
impl<'a> Unpin for Tag<'a>
impl<'a> UnwindSafe for Tag<'a>
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
Mutably borrows from an owned value. Read more