Trait napi::Task

source ·
pub trait Task: Send + Sized {
    type Output: Send + Sized + 'static;
    type JsValue: ToNapiValue + TypeName;

    // Required methods
    fn compute(&mut self) -> Result<Self::Output>;
    fn resolve(
        &mut self,
        env: Env,
        output: Self::Output
    ) -> Result<Self::JsValue>;

    // Provided methods
    fn reject(&mut self, _env: Env, err: Error) -> Result<Self::JsValue> { ... }
    fn finally(&mut self, _env: Env) -> Result<()> { ... }
}

Required Associated Types§

Required Methods§

source

fn compute(&mut self) -> Result<Self::Output>

Compute logic in libuv thread

source

fn resolve(&mut self, env: Env, output: Self::Output) -> Result<Self::JsValue>

Into this method if compute return Ok

Provided Methods§

source

fn reject(&mut self, _env: Env, err: Error) -> Result<Self::JsValue>

Into this method if compute return Err

source

fn finally(&mut self, _env: Env) -> Result<()>

Object Safety§

This trait is not object safe.

Implementors§