[−][src]Trait neon::task::Task
A Rust task that can be executed in the background on the Node thread pool.
Associated Types
type Output: Send + 'static
[src]
The task's result type, which is sent back to the main thread to communicate a successful result back to JavaScript.
type Error: Send + 'static
[src]
The task's error type, which is sent back to the main thread to communicate a task failure back to JavaScript.
type JsEvent: Value
[src]
The type of JavaScript value that gets produced to the asynchronous callback on the main thread after the task is completed.
Required methods
pub fn perform(&self) -> Result<Self::Output, Self::Error>
[src]
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.
pub fn complete<'a>(
self,
cx: TaskContext<'a>,
result: Result<Self::Output, Self::Error>
) -> JsResult<'_, Self::JsEvent>
[src]
self,
cx: TaskContext<'a>,
result: Result<Self::Output, Self::Error>
) -> JsResult<'_, Self::JsEvent>
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
pub fn schedule(self, callback: Handle<'_, JsFunction>)
[src]
Schedule a task to be executed on a background thread.
callback
should have the following signature:
function callback(err, value) {}