Skip to main content

CancelToken

Trait CancelToken 

Source
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§

Source

fn wait(&self) -> Pin<Box<dyn EventFuture>>

Get a future to wait for cancellation.

Source

fn is_cancelled(&self) -> bool

Is the token cancelled

Source

fn cancel(&self)

Cancel the token.

Source

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.

Source

fn clone_box(&self) -> Box<dyn CancelToken>

Clone the cancel token. Because the dyn requirement, CancelToken cannot be cloned directly.

Trait Implementations§

Source§

impl Debug for dyn CancelToken

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CancelToken for SimpleCancelToken

Integrate with mssf trait system.