MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / engine_create

Function engine_create

packages/native/src/lib.rs:294–316  ·  view source on GitHub ↗
(_env: Env, config: Option<JsObject>)

Source from the content-addressed store, hash-verified

292
293#[napi(js_name = "engineCreate")]
294pub 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")]
319pub fn engine_destroy(engine_id: u32) {

Callers

nothing calls this directly

Calls 3

apply_create_cfg_strictFunction · 0.85
register_engineFunction · 0.85
engine_destroyFunction · 0.85

Tested by

no test coverage detected