pub struct SqlInterruptHandle { /* private fields */ }
Expand description
Interrupt operations that use SQL
Typical usage of this type:
- Components typically create a wrapper class around an
rusqlite::Connection
(PlacesConnection
,LoginStore
, etc.) - The wrapper stores an
Arc<SqlInterruptHandle>
- The wrapper has a method that clones and returns that
Arc
. This allows passing the interrupt handle to a different thread in order to interrupt a particular operation. - The wrapper calls
begin_interrupt_scope()
at the start of each operation. The code that performs the operation periodically callserr_if_interrupted()
. - Finally, the wrapper class implements
AsRef<SqlInterruptHandle>
and callsregister_interrupt()
. This causes all operations to be interrupted when we enter shutdown mode.
Implementations§
source§impl SqlInterruptHandle
impl SqlInterruptHandle
pub fn new(conn: &Connection) -> Self
sourcepub fn begin_interrupt_scope(&self) -> Result<SqlInterruptScope, Interrupted>
pub fn begin_interrupt_scope(&self) -> Result<SqlInterruptScope, Interrupted>
Begin an interrupt scope that will be interrupted by this handle
Returns Err(Interrupted) if we’re in shutdown mode
Trait Implementations§
source§impl AsRef<SqlInterruptHandle> for SqlInterruptHandle
impl AsRef<SqlInterruptHandle> for SqlInterruptHandle
source§fn as_ref(&self) -> &SqlInterruptHandle
fn as_ref(&self) -> &SqlInterruptHandle
Converts this type into a shared reference of the (usually inferred) input type.
Auto Trait Implementations§
impl Freeze for SqlInterruptHandle
impl RefUnwindSafe for SqlInterruptHandle
impl Send for SqlInterruptHandle
impl Sync for SqlInterruptHandle
impl Unpin for SqlInterruptHandle
impl UnwindSafe for SqlInterruptHandle
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more