Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Built-In Packages

Engine::new creates an Engine with the StandardPackage loaded.

Engine::new_raw creates an Engine with no package loaded.

PackageDescriptionCoreStandardLazy-loading
LanguageCorePackagecore functions for the Rhai languageyesyesyes
ArithmeticPackagearithmetic operators (e.g. +, -, *, /) for numeric types that are not built in (e.g. u16)yesyesyes
BitFieldPackagebasic bit-field functionsnoyesyes
BasicIteratorPackagenumeric ranges (e.g. range(1, 100, 5)), iterators for arrays, strings, bit-fields and object mapsyesyesyes
LogicPackagelogical and comparison operators (e.g. ==, >) for numeric types that are not built in (e.g. u16)noyesyes
BasicStringPackagebasic string functions (e.g. print, debug, len) that are not built inyesyesyes
BasicTimePackagebasic time functions (e.g. timestamps, not available under no_time or no_std)noyesyes
MoreStringPackageadditional string functions, including converting common types to stringnoyesyes
BasicMathPackagebasic math functions (e.g. sin, sqrt)noyesyes
BasicArrayPackagebasic array functions (not available under no_index)noyesyes
BasicBlobPackagebasic BLOB functions (not available under no_index)noyesyes
BasicMapPackagebasic object map functions (not available under no_object)noyesyes
BasicFnPackagebasic methods for function pointersyesyesyes
DebuggingPackagebasic functions for debugging (requires debugging)yesyesyes
CorePackagebasic essentialsyesyesyes
StandardPackagestandard library (default for Engine::new)noyesyes

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.