1pub(super) mod properties;
2
3use super::tag::VorbisComments;
4use crate::config::ParseOptions;
5use crate::error::Result;
6use crate::ogg::constants::SPEEXHEADER;
7use properties::SpeexProperties;
8
9use std::io::{Read, Seek};
10
11use lofty_attr::LoftyFile;
12
13#[derive(LoftyFile)]
15#[lofty(read_fn = "Self::read_from")]
16pub struct SpeexFile {
17 #[lofty(tag_type = "VorbisComments")]
21 pub(crate) vorbis_comments_tag: VorbisComments,
22 pub(crate) properties: SpeexProperties,
24}
25
26impl SpeexFile {
27 fn read_from<R>(reader: &mut R, parse_options: ParseOptions) -> Result<Self>
28 where
29 R: Read + Seek,
30 {
31 let file_information = super::read::read_from(reader, SPEEXHEADER, &[], 2, parse_options)?;
32
33 Ok(Self {
34 properties: if parse_options.read_properties {
35 properties::read_properties(reader, &file_information.1, &file_information.2)?
36 } else {
37 SpeexProperties::default()
38 },
39 vorbis_comments_tag: file_information.0.unwrap_or_default(),
41 })
42 }
43}