(_env: Env, config: Option<JsObject>)
| 292 | |
| 293 | #[napi(js_name = "engineCreate")] |
| 294 | pub fn engine_create(_env: Env, config: Option<JsObject>) -> napi::Result<i64> { |
| 295 | let mut cfg = unsafe { ffi::zr_engine_config_default() }; |
| 296 | if let Some(obj) = config { |
| 297 | apply_create_cfg_strict(&mut cfg, &obj)?; |
| 298 | } |
| 299 | |
| 300 | let mut out_engine: *mut ffi::zr_engine_t = std::ptr::null_mut(); |
| 301 | let rc = unsafe { ffi::engine_create(&mut out_engine as *mut _, &cfg as *const _) }; |
| 302 | if rc != ffi::ZR_OK { |
| 303 | return Ok(rc as i64); |
| 304 | } |
| 305 | if out_engine.is_null() { |
| 306 | return Ok(ffi::ZR_ERR_PLATFORM as i64); |
| 307 | } |
| 308 | |
| 309 | match register_engine(out_engine) { |
| 310 | Ok(engine_id) => Ok(engine_id as i64), |
| 311 | Err(err) => { |
| 312 | unsafe { ffi::engine_destroy(out_engine) }; |
| 313 | Ok(err as i64) |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | #[napi(js_name = "engineDestroy")] |
| 319 | pub fn engine_destroy(engine_id: u32) { |
nothing calls this directly
no test coverage detected