pub struct CancelToken { /* private fields */ }Expand description
A QarCancelToken.
Pass it to blocking calls (through crate::BlockingOptions) and cancel
it from a callback, or create it with a timeout. The token itself is not
Send because it shares the library handle; to cancel from another thread
(a Ctrl+C handler, a watcher of stdin), hand that thread a
CancelToken::cancel_handle.
Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn cancel(&self) -> Result<()>
pub fn cancel(&self) -> Result<()>
Cancels every call that was given this token (qar_cancel_token_cancel).
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether Self::cancel has been called on this token.
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Whether the token’s timeout has passed.
Sourcepub fn cancel_handle(&self) -> CancelHandle
pub fn cancel_handle(&self) -> CancelHandle
A handle that cancels this token from any thread, for as long as the token lives.
Sourcepub fn as_raw(&self) -> *mut QarCancelToken
pub fn as_raw(&self) -> *mut QarCancelToken
The QarCancelToken handle, for a raw call (through crate::Library::raw_api) that
takes a cancel token, or for qar_cancel_token_cancel_after.
Taking the pointer is safe; using it is unsafe, under the rules of
crate::Session::as_raw for a token: valid while this CancelToken (or a clone of it)
lives, never destroyed by the caller, used on the thread that owns the token. To cancel
from another thread, use CancelToken::cancel_handle.