Skip to main content

encode

Function encode 

Source
pub fn encode(value: &Value) -> JsValue
Expand description

Engine value → C value.

§The box, and who owns it

A reference-counted value is boxed with a count of one. That count is the answer’s ownership: the caller owns the single reference, JS_DupValue makes more of them, and the last JS_FreeValue drops the box and with it the engine’s handle. Boxes are not shared between calls — two encodes of the same object give two boxes — which is invisible to C for values, and observable only through JS_VALUE_GET_PTR equality, which the C API uses for object identity. That identity is S3’s interning table; until then two encodings of one object are two pointers.