diff --git a/src/vtab/csvtab.rs b/src/vtab/csvtab.rs index 574e7d0..be7e1a3 100644 --- a/src/vtab/csvtab.rs +++ b/src/vtab/csvtab.rs @@ -9,7 +9,7 @@ use libc; use {Connection, Error, Result}; use ffi; use types::Null; -use vtab::{declare_vtab, escape_double_quote, Context, VTab, VTabCursor}; +use vtab::{declare_vtab, escape_double_quote, Context, IndexInfo, VTab, VTabCursor}; /// Register the "csv" module. pub fn load_module(conn: &Connection) -> Result<()> { @@ -131,7 +131,7 @@ impl VTab for CSVTab { Ok(vtab) } - fn best_index(&self, _info: *mut ffi::sqlite3_index_info) {} + fn best_index(&self, _info: &mut IndexInfo) {} fn open(&self) -> Result { Ok(CSVTabCursor::new(try!(self.reader()))) diff --git a/src/vtab/int_array.rs b/src/vtab/int_array.rs index 8a575f0..2bdb8e3 100644 --- a/src/vtab/int_array.rs +++ b/src/vtab/int_array.rs @@ -7,7 +7,7 @@ use libc; use {Connection, Error, Result}; use ffi; -use vtab::{declare_vtab, escape_double_quote, Context, VTab, VTabCursor}; +use vtab::{declare_vtab, escape_double_quote, Context, IndexInfo, VTab, VTabCursor}; /// Create a specific instance of an intarray object. /// The new intarray object is returned. @@ -71,7 +71,7 @@ impl VTab for IntArrayVTab { Ok(vtab) } - fn best_index(&self, _info: *mut ffi::sqlite3_index_info) {} + fn best_index(&self, _info: &mut IndexInfo) {} fn open(&self) -> Result { Ok(IntArrayVTabCursor::new()) diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index 8d7b99f..46e684e 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -45,11 +45,17 @@ pub trait VTab>: Sized { /// The `db` parameter is a pointer to the SQLite database connection that is executing the CREATE VIRTUAL TABLE statement. fn create(db: *mut ffi::sqlite3, aux: *mut libc::c_void, args: &[&[u8]]) -> Result; /// Determine the best way to access the virtual table. - fn best_index(&self, info: *mut ffi::sqlite3_index_info); + fn best_index(&self, info: &mut IndexInfo); /// Create a new cursor used for accessing a virtual table. fn open(&self) -> Result; } +pub struct IndexInfo(*mut ffi::sqlite3_index_info); + +impl IndexInfo { + // TODO +} + /// Virtual table cursor trait. pub trait VTabCursor>: Sized { /// Accessor to the associated virtual table. @@ -71,6 +77,7 @@ pub trait VTabCursor>: Sized { fn rowid(&self) -> Result; } +// FIXME clash with functions::Context pub struct Context(*mut ffi::sqlite3_context); impl Context { @@ -221,7 +228,8 @@ unsafe extern "C" fn $best_index(vtab: *mut ffi::sqlite3_vtab, info: *mut ffi::sqlite3_index_info) -> libc::c_int { let vtab = vtab as *mut $vtab; - (*vtab).best_index(info); + let mut idx_info = IndexInfo(info); + (*vtab).best_index(&mut idx_info); ffi::SQLITE_OK } unsafe extern "C" fn $destroy(vtab: *mut ffi::sqlite3_vtab) -> libc::c_int {