mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-23 09:18:54 +08:00
Extracted the preupdate_hook to a separate cargo feature.
Moved hooks and preupdate_hook into their own modules inside hooks.rs Also created an initial way to access the functions that are available during the callback.
This commit is contained in:
@@ -33,7 +33,7 @@ pub struct InnerConnection {
|
||||
pub free_update_hook: Option<unsafe fn(*mut ::std::os::raw::c_void)>,
|
||||
#[cfg(feature = "hooks")]
|
||||
pub progress_handler: Option<Box<dyn FnMut() -> bool + Send>>,
|
||||
#[cfg(feature = "hooks")]
|
||||
#[cfg(feature = "preupdate_hook")]
|
||||
pub free_preupdate_hook: Option<unsafe fn(*mut ::std::os::raw::c_void)>,
|
||||
owned: bool,
|
||||
}
|
||||
@@ -52,9 +52,9 @@ impl InnerConnection {
|
||||
#[cfg(feature = "hooks")]
|
||||
free_update_hook: None,
|
||||
#[cfg(feature = "hooks")]
|
||||
free_preupdate_hook: None,
|
||||
#[cfg(feature = "hooks")]
|
||||
progress_handler: None,
|
||||
#[cfg(feature = "preupdate_hook")]
|
||||
free_preupdate_hook: None,
|
||||
owned,
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,7 @@ impl InnerConnection {
|
||||
return Ok(());
|
||||
}
|
||||
self.remove_hooks();
|
||||
self.remove_preupdate_hook();
|
||||
let mut shared_handle = self.interrupt_lock.lock().unwrap();
|
||||
assert!(
|
||||
!shared_handle.is_null(),
|
||||
@@ -305,6 +306,10 @@ impl InnerConnection {
|
||||
#[cfg(not(feature = "hooks"))]
|
||||
#[inline]
|
||||
fn remove_hooks(&mut self) {}
|
||||
|
||||
#[cfg(not(feature = "preupdate_hook"))]
|
||||
#[inline]
|
||||
fn remove_preupdate_hook(&mut self) {}
|
||||
}
|
||||
|
||||
impl Drop for InnerConnection {
|
||||
|
Reference in New Issue
Block a user