Remove direct dependency on libsqlite3_sys

This commit is contained in:
gwenn 2018-07-15 16:15:55 +02:00
parent fe64d51422
commit 849dbda5e8
2 changed files with 7 additions and 8 deletions

View File

@ -18,6 +18,7 @@ use std::slice;
use context::set_result; use context::set_result;
use error::error_from_sqlite_code; use error::error_from_sqlite_code;
use ffi; use ffi;
pub use ffi::{sqlite3_vtab, sqlite3_vtab_cursor};
use types::{FromSql, FromSqlError, ToSql, ValueRef}; use types::{FromSql, FromSqlError, ToSql, ValueRef};
use {str_to_cstring, Connection, Error, InnerConnection, Result}; use {str_to_cstring, Connection, Error, InnerConnection, Result};

View File

@ -1,17 +1,15 @@
//! Ensure Virtual tables can be declared outside `rusqlite` crate. //! Ensure Virtual tables can be declared outside `rusqlite` crate.
extern crate libsqlite3_sys as ffi;
#[cfg(feature = "vtab")] #[cfg(feature = "vtab")]
extern crate rusqlite; extern crate rusqlite;
#[cfg(feature = "vtab")] #[cfg(feature = "vtab")]
#[test] #[test]
fn test_dummy_module() { fn test_dummy_module() {
use ffi;
use rusqlite::vtab::{ use rusqlite::vtab::{
eponymous_only_module, Context, IndexInfo, VTab, VTabConnection, VTabCursor, Values, eponymous_only_module, sqlite3_vtab, sqlite3_vtab_cursor, Context, IndexInfo, VTab, VTabConnection, VTabCursor, Values,
}; };
use rusqlite::{Connection, Result}; use rusqlite::{version_number, Connection, Result};
use std::os::raw::c_int; use std::os::raw::c_int;
let module = eponymous_only_module::<DummyTab>(); let module = eponymous_only_module::<DummyTab>();
@ -19,7 +17,7 @@ fn test_dummy_module() {
#[repr(C)] #[repr(C)]
struct DummyTab { struct DummyTab {
/// Base class. Must be first /// Base class. Must be first
base: ffi::sqlite3_vtab, base: sqlite3_vtab,
} }
impl VTab for DummyTab { impl VTab for DummyTab {
@ -32,7 +30,7 @@ fn test_dummy_module() {
_args: &[&[u8]], _args: &[&[u8]],
) -> Result<(String, DummyTab)> { ) -> Result<(String, DummyTab)> {
let vtab = DummyTab { let vtab = DummyTab {
base: ffi::sqlite3_vtab::default(), base: sqlite3_vtab::default(),
}; };
Ok(("CREATE TABLE x(value)".to_owned(), vtab)) Ok(("CREATE TABLE x(value)".to_owned(), vtab))
} }
@ -51,7 +49,7 @@ fn test_dummy_module() {
#[repr(C)] #[repr(C)]
struct DummyTabCursor { struct DummyTabCursor {
/// Base class. Must be first /// Base class. Must be first
base: ffi::sqlite3_vtab_cursor, base: sqlite3_vtab_cursor,
/// The rowid /// The rowid
row_id: i64, row_id: i64,
} }
@ -88,7 +86,7 @@ fn test_dummy_module() {
db.create_module::<DummyTab>("dummy", &module, None) db.create_module::<DummyTab>("dummy", &module, None)
.unwrap(); .unwrap();
let version = unsafe { ffi::sqlite3_libversion_number() }; let version = version_number();
if version < 3008012 { if version < 3008012 {
return; return;
} }