diff --git a/Cargo.toml b/Cargo.toml index 464849f..74951c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "marine-sqlite-connector" -version = "0.5.0" +version = "0.5.1" license = "Apache-2.0/MIT" authors = [ "Daniel Dulaney ", diff --git a/src/connection.rs b/src/connection.rs index bf6cd45..d2d8bc0 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -27,7 +27,7 @@ impl Connection { unsafe { let path = path.as_ref(); let path = path.to_string_lossy().into_owned(); - let result = ffi::sqlite3_open_v2(path, flags.0, String::new()); + let result = ffi::sqlite3_open_v2(&path, flags.0, &String::new()); match result.ret_code { ffi::SQLITE_OK => {} diff --git a/src/sqlite3_connector/import_functions.rs b/src/sqlite3_connector/import_functions.rs index c888b20..4f60898 100644 --- a/src/sqlite3_connector/import_functions.rs +++ b/src/sqlite3_connector/import_functions.rs @@ -36,7 +36,7 @@ extern "C" { const char *zVfs /* Name of VFS module to use */ ); */ - pub fn sqlite3_open_v2(filename: String, flags: i32, vfs: String) -> DBOpenDescriptor; + pub fn sqlite3_open_v2(filename: &str, flags: i32, vfs: &str) -> DBOpenDescriptor; // SQLITE_API int sqlite3_close(sqlite3*); pub fn sqlite3_close(db_handle: u32) -> i32; @@ -50,7 +50,7 @@ extern "C" { const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); */ - pub fn sqlite3_prepare_v2(db_handle: u32, sql: String) -> DBPrepareDescriptor; + pub fn sqlite3_prepare_v2(db_handle: u32, sql: &str) -> DBPrepareDescriptor; /* SQLITE_API int sqlite3_exec( @@ -63,7 +63,7 @@ extern "C" { */ pub fn sqlite3_exec( db_handle: u32, - sql: String, + sql: &str, callback_id: i32, callback_arg: i32, ) -> DBExecDescriptor; @@ -99,7 +99,7 @@ extern "C" { pub fn sqlite3_reset(stmt_handle: u32) -> i32; // SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); - pub fn sqlite3_bind_blob(stmt_handle: u32, pos: i32, blob: Vec, xDel: i32) -> i32; + pub fn sqlite3_bind_blob(stmt_handle: u32, pos: i32, blob: &Vec, xDel: i32) -> i32; // SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); pub fn sqlite3_bind_double(stmt_handle: u32, pos: i32, value: f64) -> i32; @@ -111,7 +111,7 @@ extern "C" { pub fn sqlite3_bind_null(stmt_handle: u32, pos: i32) -> i32; // SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); - pub fn sqlite3_bind_text(stmt_handle: u32, pos: i32, text: String, xDel: i32) -> i32; + pub fn sqlite3_bind_text(stmt_handle: u32, pos: i32, text: &str, xDel: i32) -> i32; // SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt) pub fn sqlite3_column_count(stmt_handle: u32) -> i32; diff --git a/src/statement.rs b/src/statement.rs index 5e00d3b..d362ce4 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -128,16 +128,16 @@ impl<'l> Drop for Statement { impl Bindable for &Value { fn bind(self, statement: &mut Statement, i: usize) -> Result<()> { match self { - &Value::Binary(ref value) => (value as &[u8]).bind(statement, i), + Value::Binary(value) => value.bind(statement, i), &Value::Float(value) => value.bind(statement, i), &Value::Integer(value) => value.bind(statement, i), - &Value::String(ref value) => (value as &str).bind(statement, i), - &Value::Null => ().bind(statement, i), + Value::String(value) => value.as_str().bind(statement, i), + Value::Null => ().bind(statement, i), } } } -impl Bindable for &[u8] { +impl Bindable for &Vec { #[inline] fn bind(self, statement: &mut Statement, i: usize) -> Result<()> { debug_assert!(i > 0, "the indexing starts from 1");