noodles_vcf/header/file_format.rs
1//! VCF header file format.
2
3/// A VCF header file format.
4#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
5pub struct FileFormat {
6 major: u32,
7 minor: u32,
8}
9
10const MAJOR_VERSION: u32 = 4;
11const MINOR_VERSION: u32 = 5;
12
13impl FileFormat {
14 /// Creates a file format.
15 ///
16 /// # Examples
17 ///
18 /// ```
19 /// use noodles_vcf::header::FileFormat;
20 /// let file_format = FileFormat::new(4, 5);
21 /// ```
22 pub const fn new(major: u32, minor: u32) -> Self {
23 Self { major, minor }
24 }
25
26 /// Returns the major version.
27 ///
28 /// # Examples
29 ///
30 /// ```
31 /// use noodles_vcf::header::FileFormat;
32 /// let file_format = FileFormat::new(4, 5);
33 /// assert_eq!(file_format.major(), 4);
34 /// ```
35 pub const fn major(&self) -> u32 {
36 self.major
37 }
38
39 /// Returns the minor version.
40 ///
41 /// # Examples
42 ///
43 /// ```
44 /// use noodles_vcf::header::FileFormat;
45 /// let file_format = FileFormat::new(4, 5);
46 /// assert_eq!(file_format.minor(), 5);
47 /// ```
48 pub const fn minor(&self) -> u32 {
49 self.minor
50 }
51}
52
53impl Default for FileFormat {
54 fn default() -> Self {
55 Self {
56 major: MAJOR_VERSION,
57 minor: MINOR_VERSION,
58 }
59 }
60}
61
62#[cfg(test)]
63mod tests {
64 use super::*;
65
66 #[test]
67 fn test_default() {
68 let file_format = FileFormat::default();
69 assert_eq!(file_format.major(), MAJOR_VERSION);
70 assert_eq!(file_format.minor(), MINOR_VERSION);
71 }
72}