Function quickjs_wasm_rs::to_qjs_value

source ·
pub fn to_qjs_value<'a>(
    context: &'a JSContextRef,
    val: &JSValue
) -> Result<JSValueRef<'a>>
Expand description

Converts a reference to a JSValue to a quickjs_wasm_rs::JSValueRef.

§Arguments

  • context - a reference to a quickjs_wasm_rs::JSContextRef. The JSValueRef is created for this JS context.
  • val - a reference to a JSValue to be converted to a JSValueRef

§Returns

  • anyhow::Result<JSValueRef>

§Example

let context = JSContextRef::default();
let js_val = "hello".into();
let qjs_val = to_qjs_value(&context, &js_val).unwrap();