1
0
mirror of https://github.com/bspeice/aeron-rs synced 2024-12-21 21:38:09 -05:00

Minor cleanup of the CnC version check

This commit is contained in:
Bradlee Speice 2019-10-02 23:11:44 -04:00
parent 27a8ce0dd4
commit 49bfb1edb9
2 changed files with 19 additions and 2 deletions

View File

@ -60,9 +60,12 @@ pub struct MetaDataDefinition {
_pid: i64,
}
/// Version code for the Aeron CnC file format
pub const CNC_VERSION: i32 = crate::sematic_version_compose(0, 0, 16);
#[cfg(test)]
mod tests {
use crate::client::cnc_descriptor::MetaDataDefinition;
use crate::client::cnc_descriptor::{MetaDataDefinition, CNC_VERSION};
use crate::driver::{DriverContext, MediaDriver};
use memmap::MmapOptions;
use std::fs::File;
@ -87,6 +90,6 @@ mod tests {
};
let metadata: &MetaDataDefinition = unsafe { &*(mmap.as_ptr().cast()) };
assert_eq!(metadata.cnc_version, 16);
assert_eq!(metadata.cnc_version, CNC_VERSION);
}
}

View File

@ -4,3 +4,17 @@
pub mod client;
pub mod control_protocol;
pub mod driver;
const fn sematic_version_compose(major: u8, minor: u8, patch: u8) -> i32 {
(major as i32) << 16 | (minor as i32) << 8 | (patch as i32)
}
#[cfg(test)]
mod tests {
use crate::sematic_version_compose;
#[test]
fn version_compose_cnc() {
assert_eq!(sematic_version_compose(0, 0, 16), 16);
}
}