Move declare_vtab into Module trait

This commit is contained in:
gwenn
2018-06-20 20:29:55 +02:00
parent eaee342025
commit 861e8edb96
4 changed files with 21 additions and 18 deletions

View File

@@ -64,6 +64,17 @@ pub trait Module {
aux: Option<&Self::Aux>,
args: &[&[u8]],
) -> Result<Self::Table>;
/// Declare the schema of a virtual table.
fn declare_vtab(db: &mut ffi::sqlite3, sql: &str) -> Result<()> {
let c_sql = try!(CString::new(sql));
let rc = unsafe { ffi::sqlite3_declare_vtab(db, c_sql.as_ptr()) };
if rc == ffi::SQLITE_OK {
Ok(())
} else {
Err(error_from_sqlite_code(rc, None))
}
}
}
/// Virtual table instance trait.
@@ -352,17 +363,6 @@ impl InnerConnection {
}
}
/// Declare the schema of a virtual table.
pub fn declare_vtab(db: &mut ffi::sqlite3, sql: &str) -> Result<()> {
let c_sql = try!(CString::new(sql));
let rc = unsafe { ffi::sqlite3_declare_vtab(db, c_sql.as_ptr()) };
if rc == ffi::SQLITE_OK {
Ok(())
} else {
Err(error_from_sqlite_code(rc, None))
}
}
/// Escape double-quote (`"`) character occurences by doubling them (`""`).
pub fn escape_double_quote(identifier: &str) -> Cow<str> {
if identifier.contains('"') {