mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
commit
301a8d0e75
@ -60,7 +60,7 @@ impl Connection {
|
|||||||
let mut c = self.db.borrow_mut();
|
let mut c = self.db.borrow_mut();
|
||||||
let r = match callback {
|
let r = match callback {
|
||||||
Some(f) => unsafe {
|
Some(f) => unsafe {
|
||||||
ffi::sqlite3_busy_handler(c.db(), Some(busy_handler_callback), mem::transmute(f))
|
ffi::sqlite3_busy_handler(c.db(), Some(busy_handler_callback), f as *mut c_void)
|
||||||
},
|
},
|
||||||
None => unsafe { ffi::sqlite3_busy_handler(c.db(), None, ptr::null_mut()) },
|
None => unsafe { ffi::sqlite3_busy_handler(c.db(), None, ptr::null_mut()) },
|
||||||
};
|
};
|
||||||
|
@ -132,7 +132,7 @@ impl InnerConnection {
|
|||||||
let r = unsafe {
|
let r = unsafe {
|
||||||
ffi::sqlite3_collation_needed(
|
ffi::sqlite3_collation_needed(
|
||||||
self.db(),
|
self.db(),
|
||||||
mem::transmute(x_coll_needed),
|
x_coll_needed as *mut c_void,
|
||||||
Some(collation_needed_callback),
|
Some(collation_needed_callback),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
17
src/trace.rs
17
src/trace.rs
@ -35,14 +35,11 @@ pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let rc = match callback {
|
let rc = match callback {
|
||||||
Some(f) => {
|
Some(f) => ffi::sqlite3_config(
|
||||||
let p_arg: *mut c_void = mem::transmute(f);
|
ffi::SQLITE_CONFIG_LOG,
|
||||||
ffi::sqlite3_config(
|
log_callback as extern "C" fn(_, _, _),
|
||||||
ffi::SQLITE_CONFIG_LOG,
|
f as *mut c_void,
|
||||||
log_callback as extern "C" fn(_, _, _),
|
),
|
||||||
p_arg,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
None => {
|
None => {
|
||||||
let nullptr: *mut c_void = ptr::null_mut();
|
let nullptr: *mut c_void = ptr::null_mut();
|
||||||
ffi::sqlite3_config(ffi::SQLITE_CONFIG_LOG, nullptr, nullptr)
|
ffi::sqlite3_config(ffi::SQLITE_CONFIG_LOG, nullptr, nullptr)
|
||||||
@ -83,7 +80,7 @@ impl Connection {
|
|||||||
let c = self.db.borrow_mut();
|
let c = self.db.borrow_mut();
|
||||||
match trace_fn {
|
match trace_fn {
|
||||||
Some(f) => unsafe {
|
Some(f) => unsafe {
|
||||||
ffi::sqlite3_trace(c.db(), Some(trace_callback), mem::transmute(f));
|
ffi::sqlite3_trace(c.db(), Some(trace_callback), f as *mut c_void);
|
||||||
},
|
},
|
||||||
None => unsafe {
|
None => unsafe {
|
||||||
ffi::sqlite3_trace(c.db(), None, ptr::null_mut());
|
ffi::sqlite3_trace(c.db(), None, ptr::null_mut());
|
||||||
@ -117,7 +114,7 @@ impl Connection {
|
|||||||
let c = self.db.borrow_mut();
|
let c = self.db.borrow_mut();
|
||||||
match profile_fn {
|
match profile_fn {
|
||||||
Some(f) => unsafe {
|
Some(f) => unsafe {
|
||||||
ffi::sqlite3_profile(c.db(), Some(profile_callback), mem::transmute(f))
|
ffi::sqlite3_profile(c.db(), Some(profile_callback), f as *mut c_void)
|
||||||
},
|
},
|
||||||
None => unsafe { ffi::sqlite3_profile(c.db(), None, ptr::null_mut()) },
|
None => unsafe { ffi::sqlite3_profile(c.db(), None, ptr::null_mut()) },
|
||||||
};
|
};
|
||||||
|
@ -143,10 +143,7 @@ impl FromSql for f64 {
|
|||||||
|
|
||||||
impl FromSql for bool {
|
impl FromSql for bool {
|
||||||
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
|
||||||
i64::column_result(value).map(|i| match i {
|
i64::column_result(value).map(|i| !matches!(i, 0))
|
||||||
0 => false,
|
|
||||||
_ => true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user