kpdb/types/version.rs
1// Copyright (c) 2016-2017 Martijn Rijkeboer <[email protected]>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use crate::common;
10
11/// The database version.
12#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
13pub struct Version {
14 /// Major version number.
15 pub major: u16,
16
17 /// Minor version number.
18 pub minor: u16,
19}
20
21impl Version {
22 /// Create a new version for a kdb2 database.
23 pub fn new_kdb2() -> Version {
24 Version {
25 major: common::KDB2_MAJOR_VERSION,
26 minor: common::KDB2_MINOR_VERSION,
27 }
28 }
29}
30
31#[cfg(test)]
32mod tests {
33
34 use super::*;
35
36 #[test]
37 fn test_new_kdb2_returns_correct_instance() {
38 let version = Version::new_kdb2();
39 assert_eq!(version.major, 3);
40 assert_eq!(version.minor, 1);
41 }
42}