Skip to main content

leodos_libcfs/os/
version.rs

1//! Safe, idiomatic wrappers for OSAL version query APIs.
2
3use crate::ffi;
4use core::ffi::CStr;
5
6/// Retrieves the OSAL version identifier string (e.g., "equuleus-rc1").
7pub fn get_version_string() -> &'static str {
8    unsafe {
9        CStr::from_ptr(ffi::OS_GetVersionString())
10            .to_str()
11            .unwrap_or("Invalid Version String")
12    }
13}
14
15/// Retrieves the OSAL version code name (e.g., "Equuleus").
16pub fn get_version_code_name() -> &'static str {
17    unsafe {
18        CStr::from_ptr(ffi::OS_GetVersionCodeName())
19            .to_str()
20            .unwrap_or("Invalid Code Name")
21    }
22}
23
24/// Retrieves the numeric OSAL version identifier.
25///
26/// The returned array contains `[Major, Minor, Revision, MissionRevision]`.
27pub fn get_version_number() -> [u8; 4] {
28    let mut numbers: [u8; 4] = [0; 4];
29    unsafe {
30        ffi::OS_GetVersionNumber(numbers.as_mut_ptr());
31    }
32    numbers
33}
34
35/// Retrieves the OSAL library build number.
36///
37/// This is a monotonically increasing number that reflects the number of changes
38/// since the epoch release.
39pub fn get_build_number() -> u32 {
40    unsafe { ffi::OS_GetBuildNumber() }
41}