summaryrefslogtreecommitdiffstats
path: root/third_party/rust/rusqlite/src/version.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/rusqlite/src/version.rs')
-rw-r--r--third_party/rust/rusqlite/src/version.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/third_party/rust/rusqlite/src/version.rs b/third_party/rust/rusqlite/src/version.rs
new file mode 100644
index 0000000000..d70af7ecf3
--- /dev/null
+++ b/third_party/rust/rusqlite/src/version.rs
@@ -0,0 +1,23 @@
+use crate::ffi;
+use std::ffi::CStr;
+
+/// Returns the SQLite version as an integer; e.g., `3016002` for version
+/// 3.16.2.
+///
+/// See [`sqlite3_libversion_number()`](https://www.sqlite.org/c3ref/libversion.html).
+#[inline]
+#[must_use]
+pub fn version_number() -> i32 {
+ unsafe { ffi::sqlite3_libversion_number() }
+}
+
+/// Returns the SQLite version as a string; e.g., `"3.16.2"` for version 3.16.2.
+///
+/// See [`sqlite3_libversion()`](https://www.sqlite.org/c3ref/libversion.html).
+#[inline]
+#[must_use]
+pub fn version() -> &'static str {
+ let cstr = unsafe { CStr::from_ptr(ffi::sqlite3_libversion()) };
+ cstr.to_str()
+ .expect("SQLite version string is not valid UTF8 ?!")
+}