Add Rhai book.
This commit is contained in:
17
doc/src/safety/sandbox.md
Normal file
17
doc/src/safety/sandbox.md
Normal file
@@ -0,0 +1,17 @@
|
||||
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.
|
||||
|
||||
```rust
|
||||
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
|
||||
```
|
Reference in New Issue
Block a user