pub struct Runtime {
    pub heap: Heap,
    /* private fields */
}
Expand description

The sljs JavaScript runtime.

It should be given a Parser implementation, e.g. NodejsParser or EsprimaParser:

use sljs::JSON;
use sljs::runtime::{Runtime, NodejsParser};

let parser = NodejsParser::new();
let mut sljs = Runtime::load(parser)
    .expect("Runtime::load");

The Runtime evaluates JavaScript source code and creates/stores crate::JSObjects.


sljs.evaluate("var x = 12")
    .expect("eval: var x");
let x = sljs.evaluate("x")
    .expect("eval: x");

assert_eq!(sljs.json_from(x), JSON::from(12.0));

Fields

heap: Heap

Implementations

Creates a sljs runtime.

Exposes the configured parser.

Takes an input and evaluates it.

Turn a JSValue into JSON

Turn a JSValue into a human-readable string.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.