use std::ffi::CStr;
use libcamera_sys::{
libcamera_version_string, LIBCAMERA_VERSION_MAJOR, LIBCAMERA_VERSION_MINOR, LIBCAMERA_VERSION_PATCH,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Version {
pub major: u32,
pub minor: u32,
pub patch: u32,
}
impl core::fmt::Display for Version {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
}
}
pub const VERSION: Version = Version {
major: LIBCAMERA_VERSION_MAJOR,
minor: LIBCAMERA_VERSION_MINOR,
patch: LIBCAMERA_VERSION_PATCH,
};
impl Version {
pub const fn current() -> Version {
VERSION
}
}
pub fn runtime_version() -> &'static str {
unsafe { CStr::from_ptr(libcamera_version_string()) }.to_str().unwrap()
}