diff --git a/rust/core/src/sync.rs b/rust/core/src/sync.rs index de26918b95..aaa4ab4888 100644 --- a/rust/core/src/sync.rs +++ b/rust/core/src/sync.rs @@ -44,6 +44,24 @@ pub trait Optionable { fn get_option_double(&self, key: Self::Option) -> Result; } +/// A handle to cancel an in-progress operation on a connection. +/// +/// This is a separated handle because otherwise it would be impossible to +/// call a `cancel` method on a connection or statement itself. +pub trait CancelHandle: Send { + /// Cancel the in-progress operation on a connection. + fn try_cancel(&self) -> Result<()>; +} + +/// A cancellation handle that does nothing (because cancellation is unsupported). +pub struct NoOpCancellationHandle; + +impl CancelHandle for NoOpCancellationHandle { + fn try_cancel(&self) -> Result<()> { + Ok(()) + } +} + /// A handle to an ADBC driver. pub trait Driver { type DatabaseType: Database; @@ -76,6 +94,11 @@ pub trait Database: Optionable