Skip to main content

rustysynth_ext/
soundfont_version.rs

1use std::io;
2use std::io::Read;
3
4use crate::binary_reader::BinaryReader;
5
6/// Represents the version of a SoundFont.
7#[derive(Debug)]
8#[non_exhaustive]
9pub struct SoundFontVersion {
10    pub(crate) major: i16,
11    pub(crate) minor: i16,
12}
13
14impl SoundFontVersion {
15    pub(crate) fn default() -> Self {
16        Self { major: 0, minor: 0 }
17    }
18
19    pub(crate) fn new<R: Read>(reader: &mut R) -> Result<Self, io::Error> {
20        let major = BinaryReader::read_i16(reader)?;
21        let minor = BinaryReader::read_i16(reader)?;
22
23        Ok(Self { major, minor })
24    }
25
26    /// Gets the major version.
27    pub fn get_major(&self) -> i32 {
28        self.major as i32
29    }
30
31    /// Gets the minor version.
32    pub fn get_minor(&self) -> i32 {
33        self.minor as i32
34    }
35}