rhai/doc/src/safety/sandbox.md
2020-06-20 12:06:17 +08:00

603 B

Sand-Boxing - Block Access to External Data

{{#include ../links.md}}

Rhai is sand-boxed so a script can never read from outside its own environment.

Furthermore, an [Engine] created non-mut cannot mutate any state outside of itself; so it is highly recommended that [Engine]'s are created immutable as much as possible.

let mut engine = Engine::new();     // create mutable 'Engine'

engine.register_get("add", add);    // configure 'engine'

let engine = engine;                // shadow the variable so that 'engine' is now immutable