2 releases
Uses old Rust 2015
0.0.2 | Jan 28, 2015 |
---|---|
0.0.1 | Dec 7, 2014 |
#3 in #encodable
43KB
895 lines
WORK IN PROGRESS.
A Rust wrapper for Duktape. Things to do before this is minimally useful:
- Handle non-UTF-8 strings.
- Call JavaScript functions by name.
- Define functions.
- Call specified Rust functions from JavaScript.
- Return errors from Rust to JavaScript.
- Convert to use
Encodable
/Decodable
everywhere.- Convert parameters to use
Encodable
. - Replace
Value
withserialize::Json
. - Convert return values to use
Decodable
.
- Convert parameters to use
- Add nice macros.
- Provide macro for calling functions.
- Provide macro for defining functions.
lib.rs
:
Rust interface to Duktape JavaScript interpreter. This is still a work in progress!
use duktape::{Context,Value,DuktapeResult};
fn add_example() -> DuktapeResult<Value<'static>> {
// Create a new JavaScript interpreter. This will be automatically
// cleaned up when `ctx` goes out of scope.
let mut ctx = try!(Context::new());
// Load some code from a string.
try!(ctx.eval("function add(x, y) { return x+y; }"));
// Call the function we defined.
ctx.call("add", &[&2.0f64, &1.0f64])
}
assert_eq!(Ok(Value::Number(3.0)), add_example());
We also have preliminary support for defining JavaScript functions using Rust, but it's still too ugly to show off.
Dependencies
~250KB