Trait Task

Source
pub trait Task:
    Send
    + Sync
    + Clone {
    type Output: Send + Sync;

    // Required method
    fn run(&self, cancel_tok: &CancellationToken) -> Result<Self::Output, Error>;
}
Expand description

A cancellable task which is meant to be run in a background thread.

For more information on the Task API, refer to the module documentation.

Required Associated Types§

Required Methods§

Source

fn run(&self, cancel_tok: &CancellationToken) -> Result<Self::Output, Error>

Run this task to completion synchronously, exiting early if the provided CancellationToken is triggered.

You probably shouldn’t call this function directly. Instead prefer higher level abstractions like TaskHandle::spawn() or bindings generated by the export_task!() macro.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§