3
0
mirror of https://github.com/isar/rusqlite.git synced 2025-04-01 03:22:58 +08:00

Merge pull request from gwenn/is_interrupted

Add binding to sqlite3_is_interrupted
This commit is contained in:
gwenn 2024-03-10 11:16:36 +01:00 committed by GitHub
commit 6036587952
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

@ -375,6 +375,11 @@ impl InnerConnection {
pub fn release_memory(&self) -> Result<()> {
self.decode_result(unsafe { ffi::sqlite3_db_release_memory(self.db) })
}
#[cfg(feature = "modern_sqlite")] // 3.41.0
pub fn is_interrupted(&self) -> bool {
unsafe { ffi::sqlite3_is_interrupted(self.db) == 1 }
}
}
impl Drop for InnerConnection {

@ -1037,6 +1037,12 @@ impl Connection {
pub fn is_readonly(&self, db_name: DatabaseName<'_>) -> Result<bool> {
self.db.borrow().db_readonly(db_name)
}
/// Determine whether or not an interrupt is currently in effect
#[cfg(feature = "modern_sqlite")] // 3.41.0
pub fn is_interrupted(&self) -> bool {
self.db.borrow().is_interrupted()
}
}
impl fmt::Debug for Connection {
@ -2206,4 +2212,14 @@ mod test {
assert_eq!((v1.as_str(), v2), (name, age));
Ok(())
}
#[test]
#[cfg(feature = "modern_sqlite")]
fn test_is_interrupted() -> Result<()> {
let db = Connection::open_in_memory()?;
assert!(!db.is_interrupted());
db.get_interrupt_handle().interrupt();
assert!(db.is_interrupted());
Ok(())
}
}