pub fn execute_tokio_future<Data: 'static + Send, Fut: 'static + Send + Future<Output = Result<Data>>, Resolver: 'static + Send + Sync + FnOnce(napi_env, Data) -> Result<napi_value>>(
    env: napi_env,
    fut: Fut,
    resolver: Resolver
) -> Result<napi_value>
Examples found in repository?
src/env.rs (lines 1112-1114)
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
  pub fn execute_tokio_future<
    T: 'static + Send,
    V: 'static + ToNapiValue,
    F: 'static + Send + Future<Output = Result<T>>,
    R: 'static + Send + Sync + FnOnce(&mut Env, T) -> Result<V>,
  >(
    &self,
    fut: F,
    resolver: R,
  ) -> Result<JsObject> {
    use crate::tokio_runtime;

    let promise = tokio_runtime::execute_tokio_future(self.0, fut, |env, val| unsafe {
      resolver(&mut Env::from_raw(env), val).and_then(|v| ToNapiValue::to_napi_value(env, v))
    })?;

    Ok(unsafe { JsObject::from_raw_unchecked(self.0, promise) })
  }