Built-In Packages
Engine::new creates an Engine with the StandardPackage loaded.
Engine::new_raw creates an Engine with no package loaded.
| Package | Description | Core | Standard | Lazy-loading |
|---|---|---|---|---|
LanguageCorePackage | core functions for the Rhai language | yes | yes | yes |
ArithmeticPackage | arithmetic operators (e.g. +, -, *, /) for numeric types that are not built in (e.g. u16) | yes | yes | yes |
BitFieldPackage | basic bit-field functions | no | yes | yes |
BasicIteratorPackage | numeric ranges (e.g. range(1, 100, 5)), iterators for arrays, strings, bit-fields and object maps | yes | yes | yes |
LogicPackage | logical and comparison operators (e.g. ==, >) for numeric types that are not built in (e.g. u16) | no | yes | yes |
BasicStringPackage | basic string functions (e.g. print, debug, len) that are not built in | yes | yes | yes |
BasicTimePackage | basic time functions (e.g. timestamps, not available under no_time or no_std) | no | yes | yes |
MoreStringPackage | additional string functions, including converting common types to string | no | yes | yes |
BasicMathPackage | basic math functions (e.g. sin, sqrt) | no | yes | yes |
BasicArrayPackage | basic array functions (not available under no_index) | no | yes | yes |
BasicBlobPackage | basic BLOB functions (not available under no_index) | no | yes | yes |
BasicMapPackage | basic object map functions (not available under no_object) | no | yes | yes |
BasicFnPackage | basic methods for function pointers | yes | yes | yes |
DebuggingPackage | basic functions for debugging (requires debugging) | yes | yes | yes |
CorePackage | basic essentials | yes | yes | yes |
StandardPackage | standard library (default for Engine::new) | no | yes | yes |
CorePackage
If only minimal functionalities are required, register the CorePackage instead.
use rhai::Engine;
use rhai::packages::{Package, CorePackage};
let mut engine = Engine::new_raw();
let package = CorePackage::new();
// Register the package into the 'Engine'.
package.register_into_engine(&mut engine);
Lazy-Loading
Use the PackageName::new_lazy() on a package built from a module with lazy-loading
enabled (via #[export_module(manifest)]).
Lazy-loaded functions are only loaded into the Engine when they are first called, which
helps conserve runtime memory usage.