pub struct FlacParser<T>{
pub stream_info: BlockStreamInfo,
pub application: BlockApplication,
pub seek_table: BlockSeekTable,
pub picture: Vec<BlockPicture>,
pub cue_sheet: BlockCueSheet,
pub padding_length: u32,
/* private fields */
}Fields§
§stream_info: BlockStreamInfo§application: BlockApplication§seek_table: BlockSeekTable§picture: Vec<BlockPicture>§cue_sheet: BlockCueSheet§padding_length: u32Implementations§
Source§impl<T> FlacParser<T>
impl<T> FlacParser<T>
Sourcepub fn new(fp: T) -> Result<Self>
pub fn new(fp: T) -> Result<Self>
Create a new FlacParser
Examples found in repository?
examples/runme.rs (line 34)
2fn main() -> std::io::Result<()> {
3 // https://drive.google.com/file/d/1fp_TYclIKZAWMwFTnxEEe4PqJCuBqHl4/view?usp=sharing
4 let mut id3_parser = ID3Parser::new("云烟成雨.mp3").unwrap();
5
6 id3_parser.parse_id3v1()?;
7 // The ID3v1 protocol does not specify the content encoding,
8 // which may be UTF-8, GBK or some other encoding,
9 // so it is not possible to decode it, so the bytecode is output directly
10 println!("{}", id3_parser.id3v1);
11
12 id3_parser.parse_id3v2()?;
13 println!("{}", id3_parser.pheader);
14 println!("{}", id3_parser.eheader);
15 println!("{}", id3_parser.footer);
16
17 // The `get` method is case insensitive,
18 // so you're allowed to pass in uppercase or lowercase characters or a mix of upper and lowercase characters,
19 // as is the `get_raw` method
20 println!("TIT2 = {:?}", id3_parser.get("TIT2").unwrap());
21 println!("TALB = {:?}", id3_parser.get("talb").unwrap());
22 println!("TPE1 = {:?}", id3_parser.get("tpe1").unwrap());
23 println!("TPE2 = {:?}", id3_parser.get("tpe2").unwrap());
24 println!("padding size = {}", id3_parser.padding_size);
25
26 // It is not recommended to print the APIC byte sequence because it is really long
27 // println!("APIC_raw = {:?}", parser.get_raw("apic").unwrap());
28
29 // Write filename.jpg to the current directory.
30 // No need to worry about multiple APIC frames in a file being overwritten by the same name.
31 // Naming rules: <filename>_mp3_<picture_type>[_index].jpg
32 id3_parser.write_image()?;
33
34 let mut flac_parser = FlacParser::new("云烟成雨.flac").unwrap();
35 flac_parser.parse()?;
36
37 // https://www.xiph.org/vorbis/doc/v-comment.html
38 // The `get` method is case insensitive
39 println!("artist = {:?}", flac_parser.get("artist").unwrap());
40
41 println!("album = {:?}", flac_parser.get("album").unwrap());
42
43 // Get all vorbis comments in the file
44 let (k, v) = flac_parser.get_all().unwrap();
45 let mut index = 0;
46 while index < k.len() {
47 println!(
48 "vorbis key = {:?}, vorbis comment = {:?}",
49 k[index], v[index]
50 );
51 index += 1;
52 }
53
54 // It is not recommended to print the APIC byte sequence because it is really long
55 // println!("picture_raw_data = {:?}", flac_parser.picture[0].data);
56
57 println!("md5 = {}", flac_parser.stream_info.md5);
58
59 println!(
60 "picture width = {}, picture width = {}, picture type = {:?}",
61 flac_parser.picture[0].width,
62 flac_parser.picture[0].height,
63 flac_parser.picture[0].pic_type
64 );
65
66 // This will write image[s] to disk
67 // Naming rules: <filename>_flac_<picture_type>[_index].jpg
68 flac_parser.write_image()?;
69
70 flac_parser.change_target("千千阙歌.flac");
71
72
73 let mut ogg_parser = OggParser::new("xhh.ogg");
74 ogg_parser.parse()?;
75 println!("ogg_vorbis_comment = {:?}", ogg_parser.get_all());
76 Ok(())
77}Sourcepub fn parse(&mut self) -> Result<()>
pub fn parse(&mut self) -> Result<()>
Start parsing flac.
Examples found in repository?
examples/runme.rs (line 35)
2fn main() -> std::io::Result<()> {
3 // https://drive.google.com/file/d/1fp_TYclIKZAWMwFTnxEEe4PqJCuBqHl4/view?usp=sharing
4 let mut id3_parser = ID3Parser::new("云烟成雨.mp3").unwrap();
5
6 id3_parser.parse_id3v1()?;
7 // The ID3v1 protocol does not specify the content encoding,
8 // which may be UTF-8, GBK or some other encoding,
9 // so it is not possible to decode it, so the bytecode is output directly
10 println!("{}", id3_parser.id3v1);
11
12 id3_parser.parse_id3v2()?;
13 println!("{}", id3_parser.pheader);
14 println!("{}", id3_parser.eheader);
15 println!("{}", id3_parser.footer);
16
17 // The `get` method is case insensitive,
18 // so you're allowed to pass in uppercase or lowercase characters or a mix of upper and lowercase characters,
19 // as is the `get_raw` method
20 println!("TIT2 = {:?}", id3_parser.get("TIT2").unwrap());
21 println!("TALB = {:?}", id3_parser.get("talb").unwrap());
22 println!("TPE1 = {:?}", id3_parser.get("tpe1").unwrap());
23 println!("TPE2 = {:?}", id3_parser.get("tpe2").unwrap());
24 println!("padding size = {}", id3_parser.padding_size);
25
26 // It is not recommended to print the APIC byte sequence because it is really long
27 // println!("APIC_raw = {:?}", parser.get_raw("apic").unwrap());
28
29 // Write filename.jpg to the current directory.
30 // No need to worry about multiple APIC frames in a file being overwritten by the same name.
31 // Naming rules: <filename>_mp3_<picture_type>[_index].jpg
32 id3_parser.write_image()?;
33
34 let mut flac_parser = FlacParser::new("云烟成雨.flac").unwrap();
35 flac_parser.parse()?;
36
37 // https://www.xiph.org/vorbis/doc/v-comment.html
38 // The `get` method is case insensitive
39 println!("artist = {:?}", flac_parser.get("artist").unwrap());
40
41 println!("album = {:?}", flac_parser.get("album").unwrap());
42
43 // Get all vorbis comments in the file
44 let (k, v) = flac_parser.get_all().unwrap();
45 let mut index = 0;
46 while index < k.len() {
47 println!(
48 "vorbis key = {:?}, vorbis comment = {:?}",
49 k[index], v[index]
50 );
51 index += 1;
52 }
53
54 // It is not recommended to print the APIC byte sequence because it is really long
55 // println!("picture_raw_data = {:?}", flac_parser.picture[0].data);
56
57 println!("md5 = {}", flac_parser.stream_info.md5);
58
59 println!(
60 "picture width = {}, picture width = {}, picture type = {:?}",
61 flac_parser.picture[0].width,
62 flac_parser.picture[0].height,
63 flac_parser.picture[0].pic_type
64 );
65
66 // This will write image[s] to disk
67 // Naming rules: <filename>_flac_<picture_type>[_index].jpg
68 flac_parser.write_image()?;
69
70 flac_parser.change_target("千千阙歌.flac");
71
72
73 let mut ogg_parser = OggParser::new("xhh.ogg");
74 ogg_parser.parse()?;
75 println!("ogg_vorbis_comment = {:?}", ogg_parser.get_all());
76 Ok(())
77}Sourcepub fn get(&mut self, query: &str) -> Option<Vec<String>>
pub fn get(&mut self, query: &str) -> Option<Vec<String>>
Get vorbis comment according to query.
Return a Vec
Examples found in repository?
examples/runme.rs (line 39)
2fn main() -> std::io::Result<()> {
3 // https://drive.google.com/file/d/1fp_TYclIKZAWMwFTnxEEe4PqJCuBqHl4/view?usp=sharing
4 let mut id3_parser = ID3Parser::new("云烟成雨.mp3").unwrap();
5
6 id3_parser.parse_id3v1()?;
7 // The ID3v1 protocol does not specify the content encoding,
8 // which may be UTF-8, GBK or some other encoding,
9 // so it is not possible to decode it, so the bytecode is output directly
10 println!("{}", id3_parser.id3v1);
11
12 id3_parser.parse_id3v2()?;
13 println!("{}", id3_parser.pheader);
14 println!("{}", id3_parser.eheader);
15 println!("{}", id3_parser.footer);
16
17 // The `get` method is case insensitive,
18 // so you're allowed to pass in uppercase or lowercase characters or a mix of upper and lowercase characters,
19 // as is the `get_raw` method
20 println!("TIT2 = {:?}", id3_parser.get("TIT2").unwrap());
21 println!("TALB = {:?}", id3_parser.get("talb").unwrap());
22 println!("TPE1 = {:?}", id3_parser.get("tpe1").unwrap());
23 println!("TPE2 = {:?}", id3_parser.get("tpe2").unwrap());
24 println!("padding size = {}", id3_parser.padding_size);
25
26 // It is not recommended to print the APIC byte sequence because it is really long
27 // println!("APIC_raw = {:?}", parser.get_raw("apic").unwrap());
28
29 // Write filename.jpg to the current directory.
30 // No need to worry about multiple APIC frames in a file being overwritten by the same name.
31 // Naming rules: <filename>_mp3_<picture_type>[_index].jpg
32 id3_parser.write_image()?;
33
34 let mut flac_parser = FlacParser::new("云烟成雨.flac").unwrap();
35 flac_parser.parse()?;
36
37 // https://www.xiph.org/vorbis/doc/v-comment.html
38 // The `get` method is case insensitive
39 println!("artist = {:?}", flac_parser.get("artist").unwrap());
40
41 println!("album = {:?}", flac_parser.get("album").unwrap());
42
43 // Get all vorbis comments in the file
44 let (k, v) = flac_parser.get_all().unwrap();
45 let mut index = 0;
46 while index < k.len() {
47 println!(
48 "vorbis key = {:?}, vorbis comment = {:?}",
49 k[index], v[index]
50 );
51 index += 1;
52 }
53
54 // It is not recommended to print the APIC byte sequence because it is really long
55 // println!("picture_raw_data = {:?}", flac_parser.picture[0].data);
56
57 println!("md5 = {}", flac_parser.stream_info.md5);
58
59 println!(
60 "picture width = {}, picture width = {}, picture type = {:?}",
61 flac_parser.picture[0].width,
62 flac_parser.picture[0].height,
63 flac_parser.picture[0].pic_type
64 );
65
66 // This will write image[s] to disk
67 // Naming rules: <filename>_flac_<picture_type>[_index].jpg
68 flac_parser.write_image()?;
69
70 flac_parser.change_target("千千阙歌.flac");
71
72
73 let mut ogg_parser = OggParser::new("xhh.ogg");
74 ogg_parser.parse()?;
75 println!("ogg_vorbis_comment = {:?}", ogg_parser.get_all());
76 Ok(())
77}Sourcepub fn get_all(&mut self) -> Result<(Vec<String>, Vec<Vec<String>>)>
pub fn get_all(&mut self) -> Result<(Vec<String>, Vec<Vec<String>>)>
Given that Vorbis allows for customized key values,
there may be key values other than those in common use,
so this method is provided to print all key-value pairs.
Examples found in repository?
examples/runme.rs (line 44)
2fn main() -> std::io::Result<()> {
3 // https://drive.google.com/file/d/1fp_TYclIKZAWMwFTnxEEe4PqJCuBqHl4/view?usp=sharing
4 let mut id3_parser = ID3Parser::new("云烟成雨.mp3").unwrap();
5
6 id3_parser.parse_id3v1()?;
7 // The ID3v1 protocol does not specify the content encoding,
8 // which may be UTF-8, GBK or some other encoding,
9 // so it is not possible to decode it, so the bytecode is output directly
10 println!("{}", id3_parser.id3v1);
11
12 id3_parser.parse_id3v2()?;
13 println!("{}", id3_parser.pheader);
14 println!("{}", id3_parser.eheader);
15 println!("{}", id3_parser.footer);
16
17 // The `get` method is case insensitive,
18 // so you're allowed to pass in uppercase or lowercase characters or a mix of upper and lowercase characters,
19 // as is the `get_raw` method
20 println!("TIT2 = {:?}", id3_parser.get("TIT2").unwrap());
21 println!("TALB = {:?}", id3_parser.get("talb").unwrap());
22 println!("TPE1 = {:?}", id3_parser.get("tpe1").unwrap());
23 println!("TPE2 = {:?}", id3_parser.get("tpe2").unwrap());
24 println!("padding size = {}", id3_parser.padding_size);
25
26 // It is not recommended to print the APIC byte sequence because it is really long
27 // println!("APIC_raw = {:?}", parser.get_raw("apic").unwrap());
28
29 // Write filename.jpg to the current directory.
30 // No need to worry about multiple APIC frames in a file being overwritten by the same name.
31 // Naming rules: <filename>_mp3_<picture_type>[_index].jpg
32 id3_parser.write_image()?;
33
34 let mut flac_parser = FlacParser::new("云烟成雨.flac").unwrap();
35 flac_parser.parse()?;
36
37 // https://www.xiph.org/vorbis/doc/v-comment.html
38 // The `get` method is case insensitive
39 println!("artist = {:?}", flac_parser.get("artist").unwrap());
40
41 println!("album = {:?}", flac_parser.get("album").unwrap());
42
43 // Get all vorbis comments in the file
44 let (k, v) = flac_parser.get_all().unwrap();
45 let mut index = 0;
46 while index < k.len() {
47 println!(
48 "vorbis key = {:?}, vorbis comment = {:?}",
49 k[index], v[index]
50 );
51 index += 1;
52 }
53
54 // It is not recommended to print the APIC byte sequence because it is really long
55 // println!("picture_raw_data = {:?}", flac_parser.picture[0].data);
56
57 println!("md5 = {}", flac_parser.stream_info.md5);
58
59 println!(
60 "picture width = {}, picture width = {}, picture type = {:?}",
61 flac_parser.picture[0].width,
62 flac_parser.picture[0].height,
63 flac_parser.picture[0].pic_type
64 );
65
66 // This will write image[s] to disk
67 // Naming rules: <filename>_flac_<picture_type>[_index].jpg
68 flac_parser.write_image()?;
69
70 flac_parser.change_target("千千阙歌.flac");
71
72
73 let mut ogg_parser = OggParser::new("xhh.ogg");
74 ogg_parser.parse()?;
75 println!("ogg_vorbis_comment = {:?}", ogg_parser.get_all());
76 Ok(())
77}Sourcepub fn write_image(&mut self) -> Result<()>
pub fn write_image(&mut self) -> Result<()>
Write image(s) to disk.
Examples found in repository?
examples/runme.rs (line 68)
2fn main() -> std::io::Result<()> {
3 // https://drive.google.com/file/d/1fp_TYclIKZAWMwFTnxEEe4PqJCuBqHl4/view?usp=sharing
4 let mut id3_parser = ID3Parser::new("云烟成雨.mp3").unwrap();
5
6 id3_parser.parse_id3v1()?;
7 // The ID3v1 protocol does not specify the content encoding,
8 // which may be UTF-8, GBK or some other encoding,
9 // so it is not possible to decode it, so the bytecode is output directly
10 println!("{}", id3_parser.id3v1);
11
12 id3_parser.parse_id3v2()?;
13 println!("{}", id3_parser.pheader);
14 println!("{}", id3_parser.eheader);
15 println!("{}", id3_parser.footer);
16
17 // The `get` method is case insensitive,
18 // so you're allowed to pass in uppercase or lowercase characters or a mix of upper and lowercase characters,
19 // as is the `get_raw` method
20 println!("TIT2 = {:?}", id3_parser.get("TIT2").unwrap());
21 println!("TALB = {:?}", id3_parser.get("talb").unwrap());
22 println!("TPE1 = {:?}", id3_parser.get("tpe1").unwrap());
23 println!("TPE2 = {:?}", id3_parser.get("tpe2").unwrap());
24 println!("padding size = {}", id3_parser.padding_size);
25
26 // It is not recommended to print the APIC byte sequence because it is really long
27 // println!("APIC_raw = {:?}", parser.get_raw("apic").unwrap());
28
29 // Write filename.jpg to the current directory.
30 // No need to worry about multiple APIC frames in a file being overwritten by the same name.
31 // Naming rules: <filename>_mp3_<picture_type>[_index].jpg
32 id3_parser.write_image()?;
33
34 let mut flac_parser = FlacParser::new("云烟成雨.flac").unwrap();
35 flac_parser.parse()?;
36
37 // https://www.xiph.org/vorbis/doc/v-comment.html
38 // The `get` method is case insensitive
39 println!("artist = {:?}", flac_parser.get("artist").unwrap());
40
41 println!("album = {:?}", flac_parser.get("album").unwrap());
42
43 // Get all vorbis comments in the file
44 let (k, v) = flac_parser.get_all().unwrap();
45 let mut index = 0;
46 while index < k.len() {
47 println!(
48 "vorbis key = {:?}, vorbis comment = {:?}",
49 k[index], v[index]
50 );
51 index += 1;
52 }
53
54 // It is not recommended to print the APIC byte sequence because it is really long
55 // println!("picture_raw_data = {:?}", flac_parser.picture[0].data);
56
57 println!("md5 = {}", flac_parser.stream_info.md5);
58
59 println!(
60 "picture width = {}, picture width = {}, picture type = {:?}",
61 flac_parser.picture[0].width,
62 flac_parser.picture[0].height,
63 flac_parser.picture[0].pic_type
64 );
65
66 // This will write image[s] to disk
67 // Naming rules: <filename>_flac_<picture_type>[_index].jpg
68 flac_parser.write_image()?;
69
70 flac_parser.change_target("千千阙歌.flac");
71
72
73 let mut ogg_parser = OggParser::new("xhh.ogg");
74 ogg_parser.parse()?;
75 println!("ogg_vorbis_comment = {:?}", ogg_parser.get_all());
76 Ok(())
77}Sourcepub fn change_target(&mut self, new_fp: T)
pub fn change_target(&mut self, new_fp: T)
As the method says.
In addition, its own data will be cleared.
Examples found in repository?
examples/runme.rs (line 70)
2fn main() -> std::io::Result<()> {
3 // https://drive.google.com/file/d/1fp_TYclIKZAWMwFTnxEEe4PqJCuBqHl4/view?usp=sharing
4 let mut id3_parser = ID3Parser::new("云烟成雨.mp3").unwrap();
5
6 id3_parser.parse_id3v1()?;
7 // The ID3v1 protocol does not specify the content encoding,
8 // which may be UTF-8, GBK or some other encoding,
9 // so it is not possible to decode it, so the bytecode is output directly
10 println!("{}", id3_parser.id3v1);
11
12 id3_parser.parse_id3v2()?;
13 println!("{}", id3_parser.pheader);
14 println!("{}", id3_parser.eheader);
15 println!("{}", id3_parser.footer);
16
17 // The `get` method is case insensitive,
18 // so you're allowed to pass in uppercase or lowercase characters or a mix of upper and lowercase characters,
19 // as is the `get_raw` method
20 println!("TIT2 = {:?}", id3_parser.get("TIT2").unwrap());
21 println!("TALB = {:?}", id3_parser.get("talb").unwrap());
22 println!("TPE1 = {:?}", id3_parser.get("tpe1").unwrap());
23 println!("TPE2 = {:?}", id3_parser.get("tpe2").unwrap());
24 println!("padding size = {}", id3_parser.padding_size);
25
26 // It is not recommended to print the APIC byte sequence because it is really long
27 // println!("APIC_raw = {:?}", parser.get_raw("apic").unwrap());
28
29 // Write filename.jpg to the current directory.
30 // No need to worry about multiple APIC frames in a file being overwritten by the same name.
31 // Naming rules: <filename>_mp3_<picture_type>[_index].jpg
32 id3_parser.write_image()?;
33
34 let mut flac_parser = FlacParser::new("云烟成雨.flac").unwrap();
35 flac_parser.parse()?;
36
37 // https://www.xiph.org/vorbis/doc/v-comment.html
38 // The `get` method is case insensitive
39 println!("artist = {:?}", flac_parser.get("artist").unwrap());
40
41 println!("album = {:?}", flac_parser.get("album").unwrap());
42
43 // Get all vorbis comments in the file
44 let (k, v) = flac_parser.get_all().unwrap();
45 let mut index = 0;
46 while index < k.len() {
47 println!(
48 "vorbis key = {:?}, vorbis comment = {:?}",
49 k[index], v[index]
50 );
51 index += 1;
52 }
53
54 // It is not recommended to print the APIC byte sequence because it is really long
55 // println!("picture_raw_data = {:?}", flac_parser.picture[0].data);
56
57 println!("md5 = {}", flac_parser.stream_info.md5);
58
59 println!(
60 "picture width = {}, picture width = {}, picture type = {:?}",
61 flac_parser.picture[0].width,
62 flac_parser.picture[0].height,
63 flac_parser.picture[0].pic_type
64 );
65
66 // This will write image[s] to disk
67 // Naming rules: <filename>_flac_<picture_type>[_index].jpg
68 flac_parser.write_image()?;
69
70 flac_parser.change_target("千千阙歌.flac");
71
72
73 let mut ogg_parser = OggParser::new("xhh.ogg");
74 ogg_parser.parse()?;
75 println!("ogg_vorbis_comment = {:?}", ogg_parser.get_all());
76 Ok(())
77}Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for FlacParser<T>where
T: Freeze,
impl<T> RefUnwindSafe for FlacParser<T>where
T: RefUnwindSafe,
impl<T> Send for FlacParser<T>where
T: Send,
impl<T> Sync for FlacParser<T>where
T: Sync,
impl<T> Unpin for FlacParser<T>where
T: Unpin,
impl<T> UnwindSafe for FlacParser<T>where
T: UnwindSafe,
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