Module javascript

Module javascript 

Source
Expand description

JavaScriptCore bindings for Ultralight.

This module provides a high-level API for working with JavaScriptCore in Ultralight. It is a thin wrapper around the C API provided by JavaScriptCore.

§Example


let object = context.global_object();
let string = JSValue::new_string(&context, "Hello, world!");
object.set_property("greeting", &string, JSPropertyAttributes::default());

// this can be called from JavaScript
let rust_callback = JSObject::new_function_with_callback(&context, |ctx, this, args| {
    Ok(JSValue::new_string(ctx, "Hello from Rust!"))
});
object.set_property("rustCallback", &rust_callback, JSPropertyAttributes::default());

Structs§

JSContext
JavaScript execution context.
JSObject
A JavaScript object.
JSPropertyAttributes
Attributes for JavaScript properties.
JSPropertyNameArray
A reference to an array of property names.
JSString
A JavaScript string.
JSTypedArray
A JavaScript Typed Array object.
JSValue
A JavaScript value.

Enums§

JSType
An enum identifying the type of a JSValue.
JSTypedArrayType
An enum identifying the Typed Array type of a JSTypedArray.

Traits§

AsJSValue
A trait for converting a type into a JSValue.