Trait neon::task::Task[][src]

pub trait Task: Send + Sized + 'static {
    type Output: Send + 'static;
    type Error: Send + 'static;
    type JsEvent: Value;
    fn perform(&self) -> Result<Self::Output, Self::Error>;
fn complete<'a>(
        cx: TaskContext<'a>,
        result: Result<Self::Output, Self::Error>
    ) -> JsResult<Self::JsEvent>; fn schedule(self, callback: Handle<JsFunction>) { ... } }

A Rust task that can be executed in a background thread.

Associated Types

The task's result type, which is sent back to the main thread to communicate a successful result back to JavaScript.

The task's error type, which is sent back to the main thread to communicate a task failure back to JavaScript.

The type of JavaScript value that gets produced to the asynchronous callback on the main thread after the task is completed.

Required Methods

Perform the task, producing either a successful Output or an unsuccessful Error. This method is executed in a background thread as part of libuv's built-in thread pool.

Convert the result of the task to a JavaScript value to be passed to the asynchronous callback. This method is executed on the main thread at some point after the background task is completed.

Provided Methods

Schedule a task to be executed on a background thread.

callback should have the following signature:

function callback(err, value) {}