9 releases

Uses old Rust 2015

0.0.9 Dec 2, 2015
0.0.8 Nov 12, 2015
0.0.6 Oct 13, 2015
0.0.2 Sep 21, 2015

#537 in Memory management

MIT license



silhouetteA Rust library providing a safe API around native abstractions for Node.

Nanny collaborates with the V8 embedding API to safely monitor stack-allocated handles to garbage-collected objects. This ensures that all objects rooted in the stack are safely tracked by the garbage collector.

A good nanny keeps the nursery safe.


A complete example can be found in the nanny-demo repository. The demo makes use of the rust-bindings npm package to completely automate the process of building and requiring a Rust module in Node.

A Node function in Rust

A JS function is represented in Rust as a function that takes a Call object and produces either a JS value or the Throw constant, indicating that an exception has been thrown. The Call object provides access to a memory management scope, which safely manages the rooting of handles to garbage-collected JS values:

fn make_an_array(call: Call) -> JS<Array> {
    let scope = call.scope; // the current scope for rooting handles
    let mut array: Handle<Array> = Array::new(scope, 3);
    try!(array.set(0, Integer::new(scope, 9000)));
    try!(array.set(1, Object::new(scope)));
    try!(array.set(2, Number::new(scope, 3.14159)));