pub trait CancelToken:
Send
+ Sync
+ 'static {
// Required methods
fn wait(&self) -> Pin<Box<dyn EventFuture>>;
fn is_cancelled(&self) -> bool;
fn cancel(&self);
fn on_cancel(&self, callback: Box<dyn FnOnce() + Send + Sync>);
fn clone_box(&self) -> Box<dyn CancelToken>;
}Required Methods§
Sourcefn wait(&self) -> Pin<Box<dyn EventFuture>>
fn wait(&self) -> Pin<Box<dyn EventFuture>>
Get a future to wait for cancellation.
Sourcefn is_cancelled(&self) -> bool
fn is_cancelled(&self) -> bool
Is the token cancelled
Sourcefn on_cancel(&self, callback: Box<dyn FnOnce() + Send + Sync>)
fn on_cancel(&self, callback: Box<dyn FnOnce() + Send + Sync>)
Register a callback to be invoked when this token is cancelled. If this token is already cancelled, the callback is invoked immediately.
§Panics (debug builds only)
Panics if a callback has already been registered.
Sourcefn clone_box(&self) -> Box<dyn CancelToken>
fn clone_box(&self) -> Box<dyn CancelToken>
Clone the cancel token. Because the dyn requirement, CancelToken cannot be cloned directly.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl CancelToken for SimpleCancelToken
Integrate with mssf trait system.