mirror of
https://github.com/bspeice/aeron-rs
synced 2024-12-22 05:48:10 -05:00
Minor cleanup of the CnC version check
This commit is contained in:
parent
27a8ce0dd4
commit
49bfb1edb9
@ -60,9 +60,12 @@ pub struct MetaDataDefinition {
|
|||||||
_pid: i64,
|
_pid: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Version code for the Aeron CnC file format
|
||||||
|
pub const CNC_VERSION: i32 = crate::sematic_version_compose(0, 0, 16);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::client::cnc_descriptor::MetaDataDefinition;
|
use crate::client::cnc_descriptor::{MetaDataDefinition, CNC_VERSION};
|
||||||
use crate::driver::{DriverContext, MediaDriver};
|
use crate::driver::{DriverContext, MediaDriver};
|
||||||
use memmap::MmapOptions;
|
use memmap::MmapOptions;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
@ -87,6 +90,6 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let metadata: &MetaDataDefinition = unsafe { &*(mmap.as_ptr().cast()) };
|
let metadata: &MetaDataDefinition = unsafe { &*(mmap.as_ptr().cast()) };
|
||||||
assert_eq!(metadata.cnc_version, 16);
|
assert_eq!(metadata.cnc_version, CNC_VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
src/lib.rs
14
src/lib.rs
@ -4,3 +4,17 @@
|
|||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod control_protocol;
|
pub mod control_protocol;
|
||||||
pub mod driver;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user