1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
pub(super) mod properties;
#[cfg(feature = "vorbis_comments")]
pub(in crate::ogg) mod write;
use super::find_last_page;
#[cfg(feature = "vorbis_comments")]
use super::tag::VorbisComments;
use crate::error::Result;
use crate::file::AudioFile;
use crate::ogg::constants::{VORBIS_COMMENT_HEAD, VORBIS_IDENT_HEAD};
use crate::tag::TagType;
use properties::VorbisProperties;
use std::io::{Read, Seek};
use lofty_attr::LoftyFile;
#[derive(LoftyFile)]
#[lofty(no_audiofile_impl)]
pub struct VorbisFile {
#[cfg(feature = "vorbis_comments")]
#[lofty(tag_type = "VorbisComments")]
#[lofty(always_present)]
pub(crate) vorbis_comments_tag: VorbisComments,
pub(crate) properties: VorbisProperties,
}
impl AudioFile for VorbisFile {
type Properties = VorbisProperties;
fn read_from<R>(reader: &mut R, read_properties: bool) -> Result<Self>
where
R: Read + Seek,
{
let file_information =
super::read::read_from(reader, VORBIS_IDENT_HEAD, VORBIS_COMMENT_HEAD)?;
Ok(Self {
properties: if read_properties { properties::read_properties(reader, &file_information.1)? } else { VorbisProperties::default() },
#[cfg(feature = "vorbis_comments")]
vorbis_comments_tag: file_information.0.unwrap(),
})
}
fn properties(&self) -> &Self::Properties {
&self.properties
}
fn contains_tag(&self) -> bool {
true
}
fn contains_tag_type(&self, tag_type: TagType) -> bool {
tag_type == TagType::VorbisComments
}
}