noodles_vcf/header/file_format.rs
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 63 64 65 66 67 68 69 70 71 72
//! VCF header file format.
/// A VCF header file format.
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct FileFormat {
major: u32,
minor: u32,
}
const MAJOR_VERSION: u32 = 4;
const MINOR_VERSION: u32 = 5;
impl FileFormat {
/// Creates a file format.
///
/// # Examples
///
/// ```
/// use noodles_vcf::header::FileFormat;
/// let file_format = FileFormat::new(4, 5);
/// ```
pub const fn new(major: u32, minor: u32) -> Self {
Self { major, minor }
}
/// Returns the major version.
///
/// # Examples
///
/// ```
/// use noodles_vcf::header::FileFormat;
/// let file_format = FileFormat::new(4, 5);
/// assert_eq!(file_format.major(), 4);
/// ```
pub const fn major(&self) -> u32 {
self.major
}
/// Returns the minor version.
///
/// # Examples
///
/// ```
/// use noodles_vcf::header::FileFormat;
/// let file_format = FileFormat::new(4, 5);
/// assert_eq!(file_format.minor(), 5);
/// ```
pub const fn minor(&self) -> u32 {
self.minor
}
}
impl Default for FileFormat {
fn default() -> Self {
Self {
major: MAJOR_VERSION,
minor: MINOR_VERSION,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default() {
let file_format = FileFormat::default();
assert_eq!(file_format.major(), MAJOR_VERSION);
assert_eq!(file_format.minor(), MINOR_VERSION);
}
}