macro_rules! sqlite3_require_version {
($version:literal) => { ... };
($version:literal, $expr:expr) => { ... };
}Expand description
Guard an expression behind an SQLite version.
This macro evaluates the SQLite version at compile time and at runtime. If both checks pass, the provided expression is evaluated. Otherwise, the macro evaluates to Error::VersionNotSatisfied.
This macro is particularly useful when interacting with ffi methods, since these may be missing on older versions of SQLite, which would cause a compilation error.
If no expression is provided, it defaults to Ok(()).
§Examples
use sqlite3_ext::{*, ffi};
use std::ffi::CStr;
pub fn sourceid() -> Result<&'static str> {
sqlite3_require_version!(3_021_000, {
let ret = unsafe { CStr::from_ptr(ffi::sqlite3_sourceid()) };
Ok(ret.to_str().expect("sqlite3_sourceid"))
})
}