use capi;
use std::ffi::CStr;
pub use self::actual::{TARGET_VERSION_STRING, TARGET_VERSION};
pub use capi::version::Compatibility;
#[cfg(feature="pa_v12_compatibility")]
mod actual {
pub const COMPATIBILITY: super::Compatibility = super::Compatibility::Latest;
pub const TARGET_VERSION_STRING: &str = "12.0.0";
pub const TARGET_VERSION: (u8, u8) = (12, 0);
}
#[cfg(not(feature="pa_v12_compatibility"))]
mod actual {
pub const COMPATIBILITY: super::Compatibility = super::Compatibility::PreV12;
pub const TARGET_VERSION_STRING: &str = "11.0.0";
pub const TARGET_VERSION: (u8, u8) = (11, 0);
}
#[deprecated(since = "2.3.0", note="use `TARGET_VERSION_STRING` instead")]
pub const BINDING_TARGET_VERSION: &str = TARGET_VERSION_STRING;
pub const API_VERSION: u8 = 12;
pub const PROTOCOL_VERSION: u16 = 32;
#[deprecated(since = "2.3.0", note="use `TARGET_VERSION` instead")]
pub const MAJOR: u8 = TARGET_VERSION.0;
#[deprecated(since = "2.3.0", note="use `TARGET_VERSION` instead")]
pub const MINOR: u8 = TARGET_VERSION.1;
#[deprecated(since = "2.3.0", note="not useful, always zero")]
pub const MICRO: u8 = 0;
#[inline(always)]
pub fn get_compatibility() -> Compatibility {
actual::COMPATIBILITY
}
#[deprecated(since = "2.3.0", note="not useful, confusing name, use `TARGET_VERSION_STRING` directly or `get_compatibility()` instead")]
#[inline(always)]
pub fn get_headers_version() -> &'static str {
#[allow(deprecated)]
BINDING_TARGET_VERSION
}
pub fn get_library_version() -> &'static CStr {
unsafe { CStr::from_ptr(capi::pa_get_library_version()) }
}
pub fn check_version(major: u8, minor: u8, _micro: u8) -> bool {
(TARGET_VERSION.0 > major) ||
(TARGET_VERSION.0 == major && TARGET_VERSION.1 > minor)
}