diff --git a/src/client/cnc_descriptor.rs b/src/client/cnc_descriptor.rs index 42ea7b0..6385354 100644 --- a/src/client/cnc_descriptor.rs +++ b/src/client/cnc_descriptor.rs @@ -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); } } diff --git a/src/lib.rs b/src/lib.rs index d988f30..f593f40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); + } +}